2016-09-08 178 views
0

使複合路徑在Adobe Illustrator中有myfile.ai通過腳本

一些compoundPathItems如何運行「對象>複合路徑>製作」或JSX發送「CTRL + 8」?與評論錯誤在這裏我得到錯誤消息「一個新的對象不能在指定的位置創建」。

#target illustrator 

if (app.documents.length > 0) { 
    var idoc = app.activeDocument; 
    var cp = idoc.compoundPathItems.add(); 
    var allPaths = activeDocument.pathItems; 
    //Select objects 
    for(var i = 0;i < allPaths.length;i++){ 
     allPaths[i].selected = true; 
    } 

    var selection = app.activeDocument.selection; 
    for (var i=0; i<selection.length; i++) { 
     selection[i].move (cp, ElementPlacement.PLACEATEND); // move selected path inside the compound path ERROR HERE 
     selection[i].evenodd = true; // necessary to determine "insideness" or to make holes. 
    } 

    alert(selection); 

回答

0
app.executeMenuCommand("compoundPath");