2014-05-22 28 views
0

不確定爲什麼這不起作用。我似乎選擇了我想要的圖層,但該圖層上的pathItems未被選中或更改。選擇選定圖層上的所有對象

var docRef = app.activeDocument; 

var layerRef = docRef.layers; 

for (i=0; i<docRef.layers.length; i++){ 
    if (layerRef[i].name === "Perflines"){ 

     var perfColor = new CMYKColor(100, 100, 0, 0); 

     layerRef[i].pathItems.selected = true; 

     layerRef[i].pathItems.strokeColor = perfColor; 

     layerRef[i].pathItems.strokeWidth = 1; 

     alert(layerRef[i].name); 

     } 
    } 

回答

2

PathItems是一個集合,沒有選擇任何屬性。

看到http://yearbookmachine.github.io/esdocs/#/Illustrator/PathItems

而且單個PathItem沒有任一選定的屬性。

看到http://yearbookmachine.github.io/esdocs/#/Illustrator/PathItem

你需要用不同的方式來選擇對象。

也許這樣(未測試)

var items = layer.pageItems; 
for(var i = 0;i < items.length;i++){ 
    if(items[i] instanceOf PathItem){ 
    items[i].selected = true; 
    } 
} 

看到http://yearbookmachine.github.io/esdocs/#/Illustrator/PageItem