• 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 add layers in master page and move contents to it in indesign using javascript

Contributor ,
Dec 14, 2022 Dec 14, 2022

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!

TOPICS
How to , Scripting

Views

150

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 , Dec 14, 2022 Dec 14, 2022

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.

 

Votes

Translate

Translate
Community Expert ,
Dec 14, 2022 Dec 14, 2022

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');

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
Contributor ,
Dec 14, 2022 Dec 14, 2022

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!

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
Community Expert ,
Dec 14, 2022 Dec 14, 2022

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.

 

ID-Tasker - most powerful tool ever created for InDesign

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
Contributor ,
Dec 14, 2022 Dec 14, 2022

Copy link to clipboard

Copied

Oh I don't have much knowledge about layers before! Thanks for Information @Robert Tkaczyk 

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
Community Expert ,
Dec 14, 2022 Dec 14, 2022

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.

 

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
Contributor ,
Dec 15, 2022 Dec 15, 2022

Copy link to clipboard

Copied

LATEST

Thank you so much @Peter Kahrel , it is working fine now

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