Hi,
I would like to algorithmically select a set of layers based on an attribute, as I could easily do manually and quickly using the search/filter options in the Layers panel. For instance, I am specifically interested in selecting all and only hidden layers. Using the layers panel, I can toggle the search/filter on and choose 'Attribute' and choose 'not visible', and then select 'All Layers' from the Selection menu. I would like to achieve that same result within a script. I could cycle through all layers and check if each layer matches my desired attribute-- but this is slow for files with many layers. I would like to achieve the layer-selection result faster than by iterating through all layers.
I thought to record an action based on using the layer panel's search/filter manually and then a 'Select All' call, but I have not had great success with this. (I thought I had it at one point but I receive an error like 'Object "" is unavailable'..)
I am thinking of a code that would be something like the following, but I have not managed to get something working..:
Code: Select all var idslct = charIDToTypeID( "slct" );
var desc46 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var list5 = new ActionList();
var ref35 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = stringIDToTypeID( "hidden" );
ref35.putEnumerated( idLyr, idOrdn, idTrgt );
list5.putReference( ref35 );
desc46.putList( idnull, list5 );
executeAction( idslct, desc46, DialogModes.NO );
Is there a typeID that I could use for the action to select multiple layers based on an attribute? Is there a good way to describe, e.g. using an ActionDescriptor, the attributes of a layer? The best I've seen so far is something along the lines of putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), stringIDToTypeID("hidden")), but again, I have not managed to make something work based on this. What is the 'Ordn' property referring to?..
Thanks for any help,
-Daniel