Simonetos The Greek
Member
- Messages
- 9
- Likes
- 0
I created this function below, to get some values from an applied bevel and emboss effect, like shading angle, shading altitude etc.
What I want to do now, is to do the same thing but for multiple layers. Exactly like this function below does with layer's color. I tried several things but my knowledge level didn't help. Any idea?
JavaScript:
alert("Angle: " + getBevelAndEmbossValues()[0] + "\nAltitude: " + getBevelAndEmbossValues()[1]);
function getBevelAndEmbossValues()
{
try
{
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('layerEffects')).getObjectValue(stringIDToTypeID('bevelEmboss'));
return [desc.getUnitDoubleValue(stringIDToTypeID('localLightingAngle')),
desc.getUnitDoubleValue(stringIDToTypeID('localLightingAltitude'))];
}
catch(e)
{
alert(e);
}
};
JavaScript:
function getLayersData()
{
var lyrs = [];
var layers = 1;
while (true)
{
ref = new ActionReference();
ref.putIndex(charIDToTypeID('Lyr '), layers);
try{var desc = executeActionGet(ref);}catch(err){alert(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;
};