6 Replies Latest reply on Sep 9, 2016 6:13 AM by K0r5hun

    Make compound path in Adobe Illustrator by script


      There are some compoundPathItems in myfile.ai

      How can i run "Object > Compound Path > Make" or send "ctrl+8" from jsx? At line with comment ERROR HERE i get error message "A new object cannot be created at the specified location".



      #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.