Action Descriptors with certain properties
Using Action Manager code you can request specific information about certain layers such as this code which gets the name of a layer given its index:
function sTID(string){
return stringIDToTypeID(string);
}function getLayerName(index){
var ref = new ActionReference();
ref.putProperty(sTID("property"), sTID("name"));
ref.putIndex(sTID("layer"), index);
var desc = executeActionGet(ref);
return desc.getString(sTID("name"));
}
And for a given layer you can request the complete ActionDescriptor using something like this:
function getLayerDescriptor(index){
var ref = new ActionReference();
ref.putIndex(sTID("layer"), index);
return executeActionGet(ref);
}
The first function is REALLY fast. The second one is much slower because it needs to find more information about the layer.
I'm wondering if anyone knows a way to request an action descriptor with only certain information about a layer.
In my trial and error I have discovered that ActionReferences can only have 1 item in their "property" so:
ref.putProperty(sTID("property"), sTID("name"));
ref.putProperty(sTID("property"), sTID("visible"));
ref.putProperty(sTID("property"), sTID("artboardEnabled"));
would result in an Action Reference where
typeIDToStringID( ref.getProperty(sTID("property"))) // "name"
If anyone has any ideas how I could go about this, it would be incredibly useful for optimizing code.
Much appreciated.
