Answered
How to get the layer style name and specific setting value
There are two styles applied to the layer below, gradient overlay and drop shadow. How to get the name and specific setting value?

There are two styles applied to the layer below, gradient overlay and drop shadow. How to get the name and specific setting value?

Thanks.
edited 2024-05-18 15:00, this might provide better readability etc.
// get keys for layer’s layer styles;
// based on code by michael l hale;
// 2024, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
if (layerDesc.hasKey(stringIDToTypeID('layerEffects')) == true) {
var effectsDesc = layerDesc.getObjectValue(stringIDToTypeID('layerEffects'));
var theEff = checkDesc3 (effectsDesc, false);
var theResult = new Array;
for (var m = 0; m < theEff.length; m++) {
if (theEff[m][2] == "DescValueType.OBJECTTYPE") {
var thisResult = checkDesc4 (effectsDesc.getObjectValue(stringIDToTypeID(theEff[1][1])), false);
theResult.push (theEff[m][1]+"\n"+thisResult.join("\n")+"\n")
}
};
alert ("layer styles:\n"+theResult.join("\n\n"));
};
};
////////////////////////////////////
////// based on code by michael l hale //////
function checkDesc3 (theDesc, theAlert) {
var c = theDesc.count;
var str = new Array;
for(var i=0;i<c;i++){ //enumerate descriptor's keys
str.push([i, typeIDToStringID(theDesc.getKey(i)), theDesc.getType(theDesc.getKey(i)), getValues (theDesc, i)]);
};
if (theAlert == true) {alert("desc\n\n"+str.join("\n\n"));
return};
return str
};
////// based on code by michael l hale //////
function checkDesc4 (theDesc, theAlert) {
var c = theDesc.count;
var str = new Array;
for(var i=0;i<c;i++){ //enumerate descriptor's keys
str.push([typeIDToStringID(theDesc.getKey(i)), getValues (theDesc, i)]);
if (theDesc.getType(theDesc.getKey(i)) == DescValueType.OBJECTTYPE) {
str.push(checkDesc4 (theDesc.getObjectValue(theDesc.getKey(i)), false).join("\n"))
};
};
if (theAlert == true) {alert("desc\n\n"+str.join("\n\n"));
return};
return str
};
////// check //////
function getValues (theDesc, theNumber) {
switch (theDesc.getType(theDesc.getKey(theNumber))) {
case DescValueType.BOOLEANTYPE:
return theDesc.getBoolean(theDesc.getKey(theNumber));
break;
case DescValueType.CLASSTYPE:
return theDesc.getClass(theDesc.getKey(theNumber));
break;
case DescValueType.DOUBLETYPE:
return theDesc.getDouble(theDesc.getKey(theNumber));
break;
case DescValueType.ENUMERATEDTYPE:
return (typeIDToStringID(theDesc.getEnumerationValue(theDesc.getKey(theNumber)))+"_"+typeIDToStringID(theDesc.getEnumerationType(theDesc.getKey(theNumber))));
break;
case DescValueType.INTEGERTYPE:
return theDesc.getInteger(theDesc.getKey(theNumber));
break;
case DescValueType.LISTTYPE:
return theDesc.getList(theDesc.getKey(theNumber));
break;
case DescValueType.OBJECTTYPE:
return (theDesc.getObjectValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getObjectType(theDesc.getKey(theNumber))));
break;
case DescValueType.REFERENCETYPE:
return theDesc.getReference(theDesc.getKey(theNumber));
break;
case DescValueType.STRINGTYPE:
return theDesc.getString(theDesc.getKey(theNumber));
break;
case DescValueType.UNITDOUBLE:
return (theDesc.getUnitDoubleValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getUnitDoubleType(theDesc.getKey(theNumber))));
break;
default:
break;
};
};

Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.