Selected items layer name

Community Beginner ,
Jan 17, 2021 Jan 17, 2021

Copy link to clipboard

Copied

I cannot figure out how to get active objects layer name, for example, if I have 3 - layers in a project | Layer_01, Layer_02, Layer_03, |  and objects are selected only in | Layer_01, Layer_03, | is there a way to get the layer name of the selected objects?Screenshot_011721_050953_PM.jpg

 
 
 
TOPICS
Scripting

Views

96

Likes

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

Enthusiast , Jan 17, 2021 Jan 17, 2021
You can use the hasSelectedArtwork property of a layer. var list = ""; for (var i = 0; i < app.activeDocument.layers.length; i++) { if (app.activeDocument.layers[i].hasSelectedArtwork) { list = list + app.activeDocument.layers[i].name + "\r"; } } alert( list );  Or the layer property of a pathItem. var list = ""; for (var i = 0; i < app.selection.length; i++) { list = list + app.selection[i].name + " - " + app.selection[i].layer.name + "\r"; } alert( list );

Likes

Translate

Translate
Enthusiast ,
Jan 17, 2021 Jan 17, 2021

Copy link to clipboard

Copied

LATEST

You can use the hasSelectedArtwork property of a layer.

 

var list = "";
for (var i = 0; i < app.activeDocument.layers.length; i++) {
    if (app.activeDocument.layers[i].hasSelectedArtwork) {
        list = list + app.activeDocument.layers[i].name + "\r";
    }
}
alert( list );

 

 Or the layer property of a pathItem.

 

var list = "";
for (var i = 0; i < app.selection.length; i++) {
    list = list + app.selection[i].name + " - " + app.selection[i].layer.name + "\r";
}
alert( list );

 

Likes

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