52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
function 删除图层3()
|
|
{
|
|
app.activeDocument.suspendHistory("Establish a mask", "批量建立蒙版()");
|
|
}
|
|
|
|
|
|
|
|
|
|
function 批量建立蒙版(){
|
|
|
|
var doc = app.activeDocument; // 获取当前文档
|
|
// 遍历所有图层
|
|
for (var i = 0; i < doc.artLayers.length; i++) {
|
|
var layer = doc.artLayers[i];
|
|
// alert(layer.name); // 显示图层名称
|
|
var layname=layer.name
|
|
var 图层名称选择 = app.activeDocument.layers.getByName(layname);
|
|
app.activeDocument.activeLayer = 图层名称选择;
|
|
载入选区();
|
|
添加图层蒙版();
|
|
}
|
|
|
|
function 载入选区() //载入选区
|
|
{
|
|
var d = new ActionDescriptor();
|
|
var r = new ActionReference();
|
|
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
|
|
d.putReference(stringIDToTypeID("null"), r);
|
|
var r1 = new ActionReference();
|
|
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("transparencyEnum"));
|
|
d.putReference(stringIDToTypeID("to"), r1);
|
|
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
|
|
|
|
}
|
|
|
|
|
|
function 添加图层蒙版() //添加图层蒙版
|
|
{
|
|
|
|
var d = new ActionDescriptor();
|
|
d.putClass(stringIDToTypeID("new"), stringIDToTypeID("channel"));
|
|
var r = new ActionReference();
|
|
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
|
|
d.putReference(stringIDToTypeID("at"), r);
|
|
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("userMaskEnabled"), stringIDToTypeID("revealSelection"));
|
|
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
|
|
|
|
|
|
}
|
|
|
|
}
|