Hi,
I am newbie to photoshop scripting but I do have few years experience with Javascript. Looking for clarification as I can't figure out what is going on here.
I was looking for solution how to get array of selected artLayers and layersSets. I found couple solutions on blogs and forums which works, but I can't figure out what that code actually does so may someone could explain it line by line or point me to normal documentation as I found http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/photoshop/pdfs/photoshop_scriptref_ js.pdf doesn't explain anything just gives list of available functions.
How ActionDescriptor, ActionReference works, how returned object by executeActionGet(ref) is structured and how Photoshop stores actions in memory.
var ref = new ActionReference();
var selectedLayers = [];
ref.putEnumerated( // Puts an enumeration type and ID into a reference along with the desired class for the reference.
//why I do need use putEnumerated? what it gives?
charIDToTypeID("Dcmn"), // document
charIDToTypeID("Ordn"), // typeOrdinal - what is ordinal?
charIDToTypeID("Trgt") //enumTarget - what?why?
)
var desc = executeActionGet(ref); // returns ActionDescriptor, how this object structure looks? how it was created?
desc = desc.getList( stringIDToTypeID( 'targetLayers' )); //returns ActionList, but what is targetLayers,who specified targetLayers? or it means it targets all layers?
for(var i=0;i<c;i++){
try{
selectedLayers.push( desc.getReference( i ).getIndex() );//gets action reference index in the ActionList
}catch(e){
// selectedLayers.push( desc.getReference( i ).getIndex()+1 ); //I commented this out as I can't understand why it is used, if we failed for i, how I can be sure that we will not fail for i+1??
}
}
If I understand correctly it gives me indexes of actions but not layers. Is that right? After this code I should somehow get artLayer+layersSets by using action indexes?
--------------------------
--------------------------
My structure of layers and groups is
Layer 4
Group4(1)
Layer 3
Group 3(1)
Group 2(1)
Layer 2
Group 1(1)
Layer 5
Layer 1
and when I select all groups ant layers script above which should return array of selected layers/groups indexes returns me this - 1,2,4,5,8,9,10,12,13. As you can see it is missing some numbers so I assume this is not array of layers indexes.
Thank you!
Tomas
Message was edited by: Tomas tarasevicius