Copy link to clipboard
Copied
Hey there,
I'm looking for a way to get the actual "layerKind" of a layer through Action manager.
Now, I know I can get a layerKind with this piece of code, but it's not the actual layerKind like the one you get through "app.activeDocument.activeLayer.kind"
function getLayerKindByIndex(theIndex) {
(r = new ActionReference ()).putProperty(stringIDToTypeID('property'), stringIDToTypeID('layerKind'));
r.putIndex(charIDToTypeID('Lyr '), theIndex);
d = executeActionGet (r);
return d.getInteger(stringIDToTypeID('layerKind'));
}
For instance, the function above will return 2 for any Adjustment layer, while "app.activeDocument.activeLayer.kind" will return a much more detailed value like "LayerKind.CURVES" and "LayerKind.HUESATURATION" and so on.
Is there any way I can get this detailed layerKind, with AM ?
Again... many thanks.
J.
So if the layer is an adjustment you could use the following code
function getLayerKindByIndex(theIndex) {
(r = new ActionReference ()).putProperty(stringIDToTypeID('property'), stringIDToTypeID('layerKind'));
r.putIndex(charIDToTypeID('Lyr '), theIndex);
d = executeActionGet (r);
if(d.getInteger(stringIDToTypeID('layerKind')) == 2);
{
(r = new ActionReference ()).putProperty(stringIDToTypeID('property'), stringIDToTypeID('adjustment'));
r.putIndex(charIDToTypeID('Lyr '), theInd
...
Copy link to clipboard
Copied
Change the return statement to the following and then try
return typeIDToStringID(d.getInteger(stringIDToTypeID('layerKind')));
-Manan
Copy link to clipboard
Copied
Copy link to clipboard
Copied
So if the layer is an adjustment you could use the following code
function getLayerKindByIndex(theIndex) {
(r = new ActionReference ()).putProperty(stringIDToTypeID('property'), stringIDToTypeID('layerKind'));
r.putIndex(charIDToTypeID('Lyr '), theIndex);
d = executeActionGet (r);
if(d.getInteger(stringIDToTypeID('layerKind')) == 2);
{
(r = new ActionReference ()).putProperty(stringIDToTypeID('property'), stringIDToTypeID('adjustment'));
r.putIndex(charIDToTypeID('Lyr '), theIndex);
d = executeActionGet (r);
var ret = d.getList(stringIDToTypeID('adjustment'))
if(ret.count)
return typeIDToStringID(ret.getObjectType(0));
}
}
So basically you will have to check layerkind and if its type needs further exploration you would need to move in as i did for adjustment. If the layer kind is 3 then its a textlayer as per the list shared by Kukurykus hence it needs no futher exploration so we stop. For completing the above code you will havw to add new if statements for all the possible values of layerkind can return and handle them accordingly.
-Manan
Copy link to clipboard
Copied
Thanks. This did the trick.
Adjustment layers seems to be the only "kind" that need further exploration.