function hasLayerFX(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
return executeActionGet(ref).hasKey(stringIDToTypeID('layerEffects'));
};
var doc = app.activeDocument;
var layers = app.activeDocument.layers;
for (var x = 0; x < layers.length; x++) {
doc.activeLayer = doc.layers[x];
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var desc = executeActionGet(ref);
var results = hasLayerFX();
if(results == true){
var stork = executeActionGet(ref).getObjectValue(stringIDToTypeID('layerEffects')).hasKey(stringIDToTypeID('frameFX'));
if(stork == true){
alert("This layer contains stork");
}
}
}
答案 0 :(得分:0)
frameFX
是一个对象描述符,就像layerEffects
一样。因此,当您确定该图层具有笔触时(使用hasKey
),您只需从图层描述符中获取这些值即可。要知道要寻找什么值,请使用Jaroslav Bereza的Action Manager Humanizer
var doc = app.activeDocument,
layers = doc.layers;
for (var x = 0; x < layers.length; x++)
{
doc.activeLayer = doc.layers[x];
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var desc = executeActionGet(ref);
if (hasStroke(desc))
{
var strokeValues = getStrokeValues(desc);
alert("Layer " + doc.layers[x].name + " has a " + strokeValues.type + " stroke with " + strokeValues.value + "px size");
}
}
function hasStroke(d)
{
if (!d.hasKey(stringIDToTypeID('layerEffects'))) return false
if (!d.getObjectValue(stringIDToTypeID('layerEffects')).hasKey(stringIDToTypeID('frameFX'))) return false
return true
}; // end of hasStroke()
function getStrokeValues(d) {
var temp = d.getObjectValue(stringIDToTypeID('layerEffects')).getObjectValue(stringIDToTypeID('frameFX'));
// possible values of the 'style' are insetFrame, centeredFrame and outsetFrame
return {
type: typeIDToStringID(temp.getEnumerationValue(stringIDToTypeID("style"))),
value: temp.getInteger(stringIDToTypeID("size"))
}
}; // end of getStrokeValues()