Copy link to clipboard
Copied
I have found following code to get all layer names in the current scene using Photoshop scripting.
var getLayerNames = function() {
var ref1 = new ActionReference();
ref1.putEnumerated(charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
var count = executeActionGet(ref1).getInteger(charIDToTypeID('NmbL'));
// get all layer names
var layerNamesSet = [];
for (var i = count; i >= 1; i--) {
var ref2 = new ActionReference();
ref2.putIndex(charIDToTypeID('Lyr '), i);
var desc = executeActionGet(ref2); // Access layer index #i
var layerSection = typeIDToStringID(desc.getEnumerationValue(stringIDToTypeID('layerSection')));
if (layerSection == 'layerSectionStart' || layerSection == 'layerSectionEnd') { // Group start and end
continue;
}
var layerName = desc.getString(stringIDToTypeID("name"));
layerNamesSet.push(layerName);
}
return layerNamesSet;
}
In above function, list of layers names is returned. But in Photoshop scripting there is a direct way to get layer comps names as in below code.
var layerComps = app.activeDocument.layerComps;
I read a lot of references for Photoshop scripting. But I couldn't find direct way to get layer names as layer comps.
I want to know, is there any way to get layer names in directly?
Copy link to clipboard
Copied
Do you want to get array of layers from layers composition? If from current one it's the same what that above function does. Perhaps you want to extract them not by that function but from layers composition? From active one or any other on a list ?
Copy link to clipboard
Copied
I want to get all layer names from the current active document.
In above example, I want to get below names of the array.
I can do it using above mentioned function. I want to know is there any way to get it in direct method as Layer comps.