通过脚本在Adobe Illustrator中创建复合路径

时间:2016-09-08 11:28:56

标签: adobe-illustrator extendscript

myfile.ai中有一些复合路径项目

如何从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);

1 个答案:

答案 0 :(得分:0)

    app.executeMenuCommand("compoundPath");