Copy link to clipboard
Copied
This should be really easy but for some reason, it just isn't working for me.
I'm using a script to create a document. It does a bunch of stuff include adding a layer. Where I am stuck is that at the end I need the original layer to be moved to the top. I know this is possible because if I just open InDesign and drag layer 2 below layer 1 in the layers panel I get the result I want.
This is the code I am using
myDocument.layers.item(1).move( myDocument, ElementPlacement.PLACEATBEGINNING );
I know that I am referencing the correct layer because I added myDocument.layers[1].name="test" and the layer I want to move to the top changes to "test" in the layers panel.
I have been googling this for a few hours and looked at every relevant question about this and no luck.
Can someone tell me what I am doing wrong?
Hi Carlos,
method move() with object Layer is working differently.
Don't know where your code is coming from.
Look it up e.g. here:
InDesign ExtendScript API (8.0)
First argument is the loactions option.
A simple
myDocument.layers.itemByName("test").move(LocationOptions.AT_BEGINNING);
should work.
FWIW: the index is counting layers from to top to bottom beginning with index number 0 .
Regards,
Uwe
Copy link to clipboard
Copied
Hi Carlos,
method move() with object Layer is working differently.
Don't know where your code is coming from.
Look it up e.g. here:
InDesign ExtendScript API (8.0)
First argument is the loactions option.
A simple
myDocument.layers.itemByName("test").move(LocationOptions.AT_BEGINNING);
should work.
FWIW: the index is counting layers from to top to bottom beginning with index number 0 .
Regards,
Uwe
Copy link to clipboard
Copied
Thanks worked perfectly.