Copy link to clipboard
Copied
app.documents[0].layers.add ({name: 'A', layerColor: UIColors.RED});
app.documents[0].layers.item('Layer 1').name = 'B';
var currentItem = app.activeDocument.pageItems.item(0);
currentItem.move(app.documents[0].layers.item('A'));
//app.documents[0].masterSpreads[0].layers.add(); //this property is not available
How to add new layer in masterSpreads[0] and move masterPage contents to that layer. I did it in pages but unable to do it with masterpage. If there is anyway help me out!
Select an item on the source layer, then run this script:
app.selection[0].itemLayer.pageItems.everyItem().itemLayer =
app.documents[0].layers.item('A');
It moves all page items on that layer to layer A.
Copy link to clipboard
Copied
You don't really move a page item to a layer, you simply change the item's layer:
currentItem.itemLayer = app.documents[0].layers.item('A');
Copy link to clipboard
Copied
HI @Peter Kahrel,
sorry I was mistaken already, actually i am trying to select current layer items and move it to newly created layer via script!
I created new layer but now I don't know how to select the current layer items and move it to new layer. If you have idea about it please help me with this point!
Copy link to clipboard
Copied
Layers are "global" - same layer is present on Pages and MasterSpreads.
So you are not adding Layers to Pages - but to the Document.
Copy link to clipboard
Copied
Oh I don't have much knowledge about layers before! Thanks for Information @Robert Tkaczyk
Copy link to clipboard
Copied
Select an item on the source layer, then run this script:
app.selection[0].itemLayer.pageItems.everyItem().itemLayer =
app.documents[0].layers.item('A');
It moves all page items on that layer to layer A.
Copy link to clipboard
Copied
Thank you so much @Peter Kahrel , it is working fine now