Copy link to clipboard
Copied
Hello!
How to get a list of ids all text layers ?
Not through DOM (elementary, a cycle with the condition if (doc.layers.kind == "LayerKind.TEXT"), but very slowly for documents with a large number of layers), but through the action manager (AAM)?
...alert(getTextLayerIDs());
function getTextLayerIDs(){
var ref = new ActionReference();
ref.putProperty( charIDToTypeID('Prpr') , charIDToTypeID('NmbL'));
ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1;
var Texts=[];
try{
activeDocument.backgroundLayer;
var i = 0; }catch(e){ var i = 1; };
for(i;i<count;i++){
if(i == 0) continue;
re
Copy link to clipboard
Copied
alert(getTextLayerIDs());
function getTextLayerIDs(){
var ref = new ActionReference();
ref.putProperty( charIDToTypeID('Prpr') , charIDToTypeID('NmbL'));
ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1;
var Texts=[];
try{
activeDocument.backgroundLayer;
var i = 0; }catch(e){ var i = 1; };
for(i;i<count;i++){
if(i == 0) continue;
ref = new ActionReference();
ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
var desc = executeActionGet(ref);
var ID = desc.getInteger(stringIDToTypeID( 'layerID' ));
if( desc.hasKey( stringIDToTypeID( 'textKey' ))) Texts.push(ID);
}
return Texts
};
Copy link to clipboard
Copied
Thank you!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now