我有一个“设计”层,其中有几个名为“ orderno”的组。
我想要一个只选择那些脚本的脚本。
我尝试了这段代码,但是我没有选择超过1个“ orderno”组
var docRef = app.activeDocument;
var layers = docRef.layers;
var myLayer = layers["design"]; //this defines the layer that you want to get the selection from
var myGroup = myLayer.groupItems["orderno"];
docRef.selection = null; //ensure there is nothing in the document selected already. this way you only get the selection you want.
for(var a=0;a<myGroup.pageItems.length;a++){ //here we are looping through each pageItem of myLayer.
var currentItem = myGroup.pageItems[a];
currentItem.selected = true;
}
我认为我在'currentItem'行中缺少某些内容...
请帮助!
答案 0 :(得分:0)
您要在遍历每个组时测试它们的名称:
var docRef = app.activeDocument;
var layers = docRef.layers;
var myLayer = layers["design"]; //this defines the layer that you want to get the selection from
docRef.selection = null; //ensure there is nothing in the document selected already. this way you only get the selection you want.
for(var a=0;a<docRef.groupItems.length;a++){
if (docRef.groupItems[a].name == "orderno"){
docRef.groupItems[a].selected = true;
}
}