Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to fast get a list of all text layers?

Mentor ,
Mar 28, 2019 Mar 28, 2019

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)?

TOPICS
Actions and scripting
744
Translate
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

Guide , Mar 28, 2019 Mar 28, 2019

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

...
Translate
Adobe
Guide ,
Mar 28, 2019 Mar 28, 2019

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

};

Translate
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
Mentor ,
Mar 28, 2019 Mar 28, 2019
LATEST

Thank you!

Translate
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