Skip to main content
Known Participant
April 14, 2024
Answered

get layer name

  • April 14, 2024
  • 1 reply
  • 447 views

Hello, how should I write a script to get the name of 'object_1'?

app.activeDocument.activeLayer.layers[0].layer(2).name

I couldn't retrieve them with this syntax.

 

Correct answer Ten A

please check the object hierarchy again.

mySubLayer has 3 objects and they are pageItems, not subLayers.

 

Currently, "object_1" is selected and the active layer is "mySubLayer".
Therefore, to access the "name" property of "object_1" from this state, do the following

 

 

//activeLayer as "mySubLayer" not "myLayer"
alert(app.activeDocument.activeLayer.pageItems[0].name)

 

 

1 reply

Ten A
Community Expert
Ten ACommunity ExpertCorrect answer
Community Expert
April 14, 2024

please check the object hierarchy again.

mySubLayer has 3 objects and they are pageItems, not subLayers.

 

Currently, "object_1" is selected and the active layer is "mySubLayer".
Therefore, to access the "name" property of "object_1" from this state, do the following

 

 

//activeLayer as "mySubLayer" not "myLayer"
alert(app.activeDocument.activeLayer.pageItems[0].name)