我对javascripting很陌生,正在尝试在photoshop中处理图层加载,以将每个图层的加载选择输出为AI路径。
我遇到的问题是理解 selection.load 的通道参数。
在 photoshop 中,负载选择的下拉列表将通道名称显示为"layer_7透明度"。 但是通过这个似乎不起作用。
for(a=2;a<=AD.layers.length;a++){
AD.layers[a-2].visible = 0;
AD.layers[a-1].visible = 1;
if((checkArray[a-1]!= 1)&&(checkArray[a-1]!= 2)){
var channel = AD.channels.getByName(AD.layers[a-1].name+" Transparency");
AD.selection.load(channel, SelectionType.REPLACE, false);
AD.selection.makeWorkPath(1.0)
newAIFile = new File(tempFolder+"/"+AD.layers[a-1].name+".ai");
AD.exportDocument(newaiFile , ExportType.ILLUSTRATORPATHS , exportOptions)
}
}
在脚本中,集合中的第一层是最后添加的层。 它位于 Document.artLayers
集合中的索引 0。
// Get a reference to the first layer in the document
var layerRef:Layer = app.activeDocument.layers.index(0);
// Get a reference to a layer by name
var baseLayer:Layer = app.activeDocument.artLayers.getByName("Background");
由于图层集可以嵌套,因此您可能需要向下钻取所包含的图层集才能到达特定图层或图层集:
app.activeDocument.layerSets.index(0).layerSets.index(0);
引用
- 脚本 Photoshop:使用图层