Copy link to clipboard
Copied
I have this function which get some layers data and then do some stuff. If you see at line 24, there is an if condition "if (lyr.type == layerType" and for example, if I want to choose shape layers I have to put the number 4 using a prompt. My question is, where does this number come from? Why 4? What is 3 or 5? Where can I find a list of what is what?
Thank you for your time!!!
function getLayersData()
{
var lyrs = [];
var layers = 1;
while (true)
{
ref = new ActionReference();
ref.putIndex(charIDToTypeID('Lyr '), layers);
try
{
var desc = executeActionGet(ref);
}
catch (err)
{
break;
}
var lyr = {};
lyr.type = desc.getInteger(stringIDToTypeID("layerKind"));
lyr.name = desc.getString(charIDToTypeID("Nm "));
lyr.id = desc.getInteger(stringIDToTypeID("layerID"));
if (lyr.type == layerType && lyr.name.match(layerName))
{
var adj = desc.getList(stringIDToTypeID("adjustment")).getObjectValue(0);
if (adj.hasKey(stringIDToTypeID("color")))
{
var curColor = new SolidColor();
curColor.rgb.red = adj.getObjectValue(stringIDToTypeID("color")).getUnitDoubleValue(stringIDToTypeID("red"));
curColor.rgb.green = adj.getObjectValue(stringIDToTypeID("color")).getUnitDoubleValue(stringIDToTypeID("grain"));
curColor.rgb.blue = adj.getObjectValue(stringIDToTypeID("color")).getUnitDoubleValue(stringIDToTypeID("blue"));
lyr.color = curColor;
if (lyr.color.rgb.hexValue == currentColor[0])
{
lyrs.push(lyr);
}
}
}
layers++;
}
return lyrs
};
Copy link to clipboard
Copied
You can't without trying. In Domestic Oriented Model they are specified but not by Action Manager.
Copy link to clipboard
Copied
I am not sure if I get what you mean...
Copy link to clipboard
Copied
DOM is based on AM, and thanks to favour or creators in that first there are used names instead of numbers.
Copy link to clipboard
Copied
Create various types of layer and run this against each layer.
You should find that some types have the same number I.E Curves and Levels are 2
alert(getAdjType());
function getAdjType(){
var ref = new ActionReference();
ref.putIdentifier(charIDToTypeID( "Lyr " ), activeDocument.activeLayer.id );
var desc = executeActionGet(ref);
var kind = desc.getInteger(stringIDToTypeID("layerKind"));
if( desc.hasKey( stringIDToTypeID( "adjustment" ) ) ){
return "Kind = " + kind + " Name = " + typeIDToStringID(desc.getList (stringIDToTypeID("adjustment")).getClass (0));
}else{
return "Kind = " + kind;
}
};
Copy link to clipboard
Copied
Thank you very much my friend, this is what I was looking for!!!
Copy link to clipboard
Copied
I found these six basic types of layers. I leave them here if someone else need them and if I found more I'll post them...
1 for pixel layers.
2 for adjustment layers.
3 for text layers (or type layers).
4 for shape layers.
5 for smart object.
7 for groups or artboards.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
r-bin Thank you very much for the link!!!