如何使用JavaScript不带比例的Photoshop识别剪贴蒙版?

时间:2019-06-19 13:13:39

标签: javascript photoshop adobe-illustrator photoshop-script

我想从psd中找到所有剪切蒙版层。但是问题是我们如何在当前使用的以下代码中确定psd中的剪贴蒙版层。

我尝试了这个How to identify clipping masks in Photoshop using JavaScript

但是它不起作用。

directus_files

1 个答案:

答案 0 :(得分:1)

var doc = activeDocument,
    layers = 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);
    if (desc.hasKey(charIDToTypeID('Grup')) && desc.getBoolean(charIDToTypeID('Grup')))
    {
        alert("this is Clipping Mask Layer: " + doc.activeLayer.name);
    }
}