Skip to main content
rywalker
Known Participant
June 28, 2019
Answered

Action Descriptors with certain properties

  • June 28, 2019
  • 1 reply
  • 731 views

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.

This topic has been closed for replies.
Correct answer greless

Unfortunately this is not possible,Please see here

How to get more than 2 layer properties

1 reply

greless
grelessCorrect answer
Inspiring
June 29, 2019

Unfortunately this is not possible,Please see here

How to get more than 2 layer properties