2016-09-08 140 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");