Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Re: Indesign Scripting: Loop through Layers

$
0
0

Did you all test your solutions in a Real World Scenario?

 

Theoretically it should work this way (if we neglect that a layer could be invisible, too), but even without the problem of  invisible layers app.pasteInPlace() prefers to paste into the original layer, if the option "Paste Remembers Layers" is checked.

 

So I would recommend to do the following:

var oldPasteRem = app.clipboardPreferences.pasteRemembersLayers;//uncheck "Paste Remembers Layers"
app.clipboardPreferences.pasteRemembersLayers = falsefor (i = 0; i < app.activeDocument.layers.length; i++) {     //Maybe the user does not want objects pasted to invisible layers:     if(app.activeDocument.layers[i].visible == true&& app.activeDocument.layers[i].locked == false) {        app.activeDocument.activeLayer = app.activeDocument.layers[i];        app.pasteInPlace();    };};//Restore the old condition:
app.clipboardPreferences.pasteRemembersLayers = oldPasteRem;

 

 

Uwe


Viewing all articles
Browse latest Browse all 37788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>