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

How can i select a nested layer in parent layer by jsx??

Explorer ,
May 26, 2019 May 26, 2019

Hello,

How can i select the layer name <oval> or <3> in a nested layer of parent layer hello1 with jsx?

i try literally everything i found. but nothing works.

コメント 2019-05-27 021624.png

TOPICS
Scripting
1.3K
Translate
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 26, 2019 May 26, 2019

Hi,

As far as i know InDesign does not have nested layers, looking at the screenshot you have given you have just one layer named "Layer 1" after that hello1 could be a textframe or a group with other textframes or groups nested within it. One way to reach the group you need is to give it a name(double click the group on the layers panel and when the text becomes editable write the name you want to assign), and the search the document for a group with this name. Suppose you named the group gp the

...
Translate
Community Expert ,
May 26, 2019 May 26, 2019

Hi,

As far as i know InDesign does not have nested layers, looking at the screenshot you have given you have just one layer named "Layer 1" after that hello1 could be a textframe or a group with other textframes or groups nested within it. One way to reach the group you need is to give it a name(double click the group on the layers panel and when the text becomes editable write the name you want to assign), and the search the document for a group with this name. Suppose you named the group gp then the following should work

var pi = app.documents[0].allPageItems

for(var i = 0 ; i < pi.length; i++)

{

    if(pi.name == "gp")

    {

          var pg = pi.pageItems.everyItem().getElements() //pg will contain the elements of the group, i.e. the oval and textframe with 3 in your case

          //Select the group

          app.select(pi)

          //If you want to select individual items of the group you could use pg[0], pg[1] etc as argument in the above select statement

          break;

    }

}

However if you want that the group you choose should follow a particular hierarchy i.e. should be a group nested within a textframe etc then you will have to share your InDesign document as i can't guess whether an item is a group or a textframe just by looking at the screenshot you gave.

-Manan

Translate
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
Advisor ,
May 26, 2019 May 26, 2019

Please read this post InDesign Sublayers it should point you in the right direction of targeting page items.

Regards,

Mike

Translate
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 ,
May 27, 2019 May 27, 2019

Hi OfficialNeaven ,

as Manan and Mike already pointed out:

There are no sublayers with InDesign.

What you are seeing in the Layers panel are Layers plus their items on the active spread.

And the items are showing nested structures. Items structured inside other items:

Group items.

Text frames with anchored objects.

Text frames with tables where cells are graphic cells.

Graphic frames with items inside ( pasted inside )

Also possible but nothing of your screenshot indicates this:
Multistate objects or button objects showing states with nested items.

FWIW: If the names of objects are in arrow brackets like that: <Name> , it would mean the items are not custom named.

The generic name is showing up. In case of text frames with text contents the first few characters of the frame are used to indicate there is a text frame.

A user could name an object on the spread through the Layers panel. This was done in your sample with the nested structure now named hello1, hello2 and hello. To reveal the generic name simply rename the item to nothing.

Regards,
Uwe

Translate
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
Explorer ,
May 27, 2019 May 27, 2019

hello everyone.

i try Manan script, and funny thing happens.

In my iMac at work. i was able to select <楕円> layer, but not all of them(my company from japanese, <楕円> means Oval).

And only some of unnamed layer can be select, some none. I dont know why.

When i try to rename that layer in another Japanese word. It's work.

This is from my PC at home. As you can see. My object is an anchor group(1 text frame and 1 Oval has stroke).

Translate
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 ,
May 27, 2019 May 27, 2019

Can you share a document specifying what exactly is not being selected. I will debug and let you know whats happening

-Manan

Translate
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
Explorer ,
May 31, 2019 May 31, 2019
LATEST

i found the way to make it work. big thanks

Translate
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