/ Id-Extras Forum / Object Styles and Object Layer Options
-
Author
-
Wonderboy
ParticipantIs there a way to loop through all pages in document, select an object by object style name, and change the Object Layer Options to show a specific layer that is turned off? Or show all layers using the Object Layer Options?
This would prevent me from having to go to each linked PDF on each page and turning on the layers using the Object Layer Options.
-
This topic was modified 1 year, 11 months ago by
~~Ariel~~.
~~Ariel~~
ParticipantYes, there is, but I would set up an object find query (just as one would do with the UI) to find all such objects based on object style.
Something like this:Code:app.findObjectPreferences = null;
app.findObjectPreferences.appliedObjectStyles = myDoc.objectStyles.itemByName(“YourStyleNameGoesHere”);
app.findChangeObjectOptions.objectType = ObjectTypes.ALL_FRAMES_TYPE;
f = document.findObject();Wonderboy
ParticipantI was thinking the same thing but couldn’t figure out the proper syntax.
Does the script you provided turn on all the layers for the Object Layer Options?
I’ve seen some stuff about graphicLayers.GraphicLayerOptions but im just not sure whats the right syntax and how to write it out.
~~Ariel~~
ParticipantNo, the script just gets a list of found objects.
To switch layer visibility on and off I think (from memory) it’s something likeCode:myObject.itemLayer.visible = true; // or falseEDIT: I fixed the syntax, the above is now correct.
Wonderboy
Participantim still confused at how to write all this up so that it will turn off a layer within the Object Layer Options window
~~Ariel~~
ParticipantNot sure what the confusion is.
If you have a page item (say a text frame, or rectangle or whatever), it has a property called itemLayer, which will give you a reference to the layer that the item is on.
And setting a layer to true or false will turn it on or off in the layers panel, e.g.:Code:myItem.itemLayer.visible = true;Obviously you don’t have to get a reference to a layer through a page item, you can access all the layers in the document through the
Code:document.layerscollection.
Wonderboy
ParticipantDoes document layers also affect layers in a linked document?
for example – i have a illustrator file that i have placed on a page. i right click on the illustrator link and select Object Layers Options. This brings up the illustrator file layers and i can turn on or off different layers to this illustrator file. Now lets say i have 10 indesign pages, each page has a linked illustrator file with an assigned object style “Artwork”.
Is it possible to write a script that will look for any object style name Artwork within the indesign document, and turn on or off a specific layer to the illustrator file?
~~Ariel~~
ParticipantAh, I misunderstood, I thought you were talking about regular document layers.
What you’re asking should be doable.
A graphic item has a graphicLayers property, and each layer can be turned on or off with myLayer.currentVisibility which is r/w.
That’s where I’d start playing around.Wonderboy
Participantso far i’ve been trying to mess around with this
Code:var myDocument = app.activeDocument;
var docLength = myDocument.pages.length;
var myPages = myDocument.pagesfor (var i = 0; i < docLength; i++) { alert("hello") var labelPlaceholder = myDocument.allGraphics; var labelArtwork = labelPlaceholder[0]; var artworkLayers = labelArtwork.graphicLayerOptions.graphicLayers; artworkLayers.item("Die Copy").currentVisibility = true; }
i keep getting Object is Invalid on the currentVisability line
Wonderboy
Participantafter playing around i made progress….
Code:var myDocument = app.activeDocument;
var docLength = myDocument.pages.length;
var myPages = myDocument.pagesfor (var i = 0; i < docLength; i++) { var labelPlaceholder = myDocument.allGraphics; var labelArtwork = labelPlaceholder[0]; var artworkLayers = labelArtwork.graphicLayerOptions.graphicLayers; // artworkLayers.item("Die Copy").currentVisibility = true; // alert(artworkLayers.length) artworkLayers[0].currentVisibility = true; }
this works at communicating with the pdf layers, not i just need to loop through each page and do the same thing to each pdf on each page.
Wonderboy
Participantgot it working…
Code:var myDocument = app.activeDocument;
var docLength = myDocument.pages.length;
var myPages = myDocument.pagesfor (var i = 0; i < docLength; i++) { var labelPlaceholder = myPages[i].allGraphics; var labelArtwork = labelPlaceholder[0]; var artworkLayers = labelArtwork.graphicLayerOptions.graphicLayers; artworkLayers[0].currentVisibility = true; }
~~Ariel~~
ParticipantWell done!
The code here will only work on the first graphic on each page. Is that what you wanted? -
This topic was modified 1 year, 11 months ago by
-
AuthorPosts
Tagged: Scripting