1 Reply Latest reply on Mar 23, 2014 4:41 PM by Zenek Demar

    I'm having trouble finishing up with Compound Paths

    sbelleque

      OK, I'm a novice here so here's my script. It works really well like it sits. It basically takes two objects in a large group and aligns them. I want to make each two objects combinded into a single compound path. I have tried multiple things and they all just kick out errors and what not. I can't seem to get my head around the vocabulary for the scripting but the darkness is starting to fade the more I do.

       

      #target Illustrator

                var idoc = app.activeDocument;

                var pi =idoc.compoundPathItems;

                var numn = prompt ("How Many Names?", "Enter Number of Names");

                var dd = prompt ("How far below name is the number?", "Enter Drop Distance");

                var nH = prompt ("How tall are the names?", "Enter Name Height in Inches");

                dd = parseFloat (dd);

                numn = parseInt (numn);

                nH = parseFloat (nH);

       

      for (j=0; j<numn; j++) {

                          var num = j + numn;

                          var numpath = pi[num];

                          var npath = pi[j];

                          var nName = 'name' + j;

                          var numName = 'number' + j;

                          var centWidth = pi[j].width / 72;

                          var centN = pi[num].width / 72;

                          var adjNum = (centWidth - centN) / 2;

                          var fhp = j*9.5*72;

                          var fvp = 0;

                          var nhp = (j*9.5*72) + (adjNum * 72);

                          var nvp = ((dd*72) + (nH * 72))*-1;

             

                          pi[j].name = nName;

                          pi[num].name = numName;

                          npath.position = [fhp,fvp];

                          numpath.position = [nhp,nvp];

       

      // Would Like to combine the aligned items into a single compound item.

       

       

      }

        • 1. Re: I'm having trouble finishing up with Compound Paths
          Zenek Demar Level 1

          select few objects and try this to build up a new compound path.

           

          #target illustrator
          
          var doc = activeDocument; 
          var sel = doc.selection;
          
          var newCompPath = doc.activeLayer.compoundPathItems.add()
          
          if (sel.length > 0) {
             for (var i=0; i<sel.length; i++) {
                  sel[i].evenodd = true;
                  sel[i].move(newCompPath, ElementPlacement.INSIDE);
                 }
             }