Copy link to clipboard
Copied
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.
1 Correct answer
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
...Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Please read this post InDesign Sublayers it should point you in the right direction of targeting page items.
Regards,
Mike
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
Can you share a document specifying what exactly is not being selected. I will debug and let you know whats happening
-Manan
Copy link to clipboard
Copied
i found the way to make it work. big thanks

