select 所有名称为 X 的群组的 Illustrator 脚本
Illustrator Script to select all groups with named X
我有一个层 "design",其中有几个名为 "orderno" 的组。
我想要一个只支持 select 那些的脚本。
我尝试了此代码,但我在 select 超过 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' 行遗漏了一些东西...
请帮忙!
您想在遍历每个组时测试它们的名称:
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;
}
}
我有一个层 "design",其中有几个名为 "orderno" 的组。
我想要一个只支持 select 那些的脚本。
我尝试了此代码,但我在 select 超过 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' 行遗漏了一些东西...
请帮忙!
您想在遍历每个组时测试它们的名称:
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;
}
}