• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to move layer to top layer

New Here ,
May 16, 2017 May 16, 2017

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?

TOPICS
Scripting

Views

3.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 16, 2017 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

Votes

Translate

Translate
Community Expert ,
May 16, 2017 May 16, 2017

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 16, 2017 May 16, 2017

Copy link to clipboard

Copied

LATEST

Thanks worked perfectly.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines