Сценарий Illustrator для выбора всех групп с именем X - PullRequest
0 голосов
/ 29 октября 2018

У меня есть слой "design" с несколькими группами с именем "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' ...

пожалуйста, помогите!

1 Ответ

0 голосов
/ 29 октября 2018

Вы хотите проверить имя каждой группы во время их цикла:

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;  
    }
}
...