Copy link to clipboard
Copied
I need to toggle Rectangle Frames to non printing to send to a client so that their editor can review the text & flow. The project is too far along to transfer all of the images to another layer and then just turn off the layer.
I know I can do it individually for each item, however that can take hours everytime I need to send a copy to the client.
I've looked but have not found a script or utility that would "en mass" change the status of all Rectangle Frames in a particular layer to non printing.
Looking forward to your suggestions.
Copy link to clipboard
Copied
Here you go. Setting nonprinting is as much/little effort as moving the rectangles to a particular layer.
> in a particular layer
In the script's text, replace xyz with the name of your layer.
r = app.documents[0].rectangles.everyItem().getElements();
for (i = r.length-1; i >= 0; i--) {
if (r[i].itemLayer.name === 'xyz') {
r[i].nonprinting = true;
}
}
Copy link to clipboard
Copied
Beat me to the punch, @Peter Kahrel! But perhaps some are anchored. allGraphics.parent might be more efficient than allPageItems though in my example (and accounts for graphics not in rectangles)
Copy link to clipboard
Copied
> But perhaps some are anchored
True. Hadn't thought of that.
Copy link to clipboard
Copied
var layerName = "Layer X";
var apis = app.activeDocument.allPageItems;
var i = apis.length;
while(i--) {
if (apis[i] instanceof Rectangle && apis[i].itemLayer.name == layerName) {
apis[i].nonprinting = true; //change true to false to undo
}
}
EDIT: Here's a refined version that would nonprint all graphic containers, not just rectangles.
var layerName = "Layer X";
var apis = app.activeDocument.allGraphics;
var i = apis.length;
var p;
while(i--) {
p= apis[i].parent;
if (p.itemLayer.name == layerName) {
p.nonprinting = true; //change true to false to undo
}
}
Copy link to clipboard
Copied
There's a script here that can move all images to a new layer - not sure if it works for your needs
https://creativepro.com/topic/script-to-move-all-imagesgraphics-to-a-new-layer/
If it would be worth your while to create an Object Style
And select one of the images you want to set to non printing
And create a style for it
In the Attributes set it to non-printing and redefine the style
then you just have to turn off the non printing for 1 image and redefine the style to toggle it
Perhaps it can be scripted.
Copy link to clipboard
Copied
Well, I went to take up the dinner and two scripts written while I was away .. ha ha great stuff.
Copy link to clipboard
Copied
Aha -- Brian beat me to it. Two different approaches for you.
P.
Copy link to clipboard
Copied
Gentlemen, I thank you for the solutions and the effort. Your work really drives home the fact that I need to start my journey in the JavaScript world.