Skip to main content
carlosn21996940
Participant
May 16, 2017
Answered

How to move layer to top layer

  • May 16, 2017
  • 1 reply
  • 3648 views

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?

This topic has been closed for replies.
Correct answer Laubender

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

1 reply

LaubenderCommunity ExpertCorrect answer
Community Expert
May 16, 2017

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

carlosn21996940
Participant
May 16, 2017

Thanks worked perfectly.