5 Replies Latest reply on Jul 15, 2014 8:20 AM by Muppet Mark

    artboard coordinate

    PYLerayer

      Hi,

       

      I'm a newbie concerning scripting and i need your help.

       

      Here is the situation : In Illustrator CS6, I have one artboard, and a second one, which has the same size than the first. The right side of one is on the left side of the other. Then we can export two .eps files to publish books.

       

      Now, I would like to resize the first artboard as the new size becomes (artboard 0 + artboard 1) by writing a script (because there are a lot of files to work on). Or eventually create a third artboard, whose size is still (artboard0 + artboard1).

       

      The problem is that every file has different artboards : the height can change but the horizontal size stays the same.

       

      Here is my opinion, and 3 alternatives.

           -We should write a script which makes the first artboard (artboard 0) twice bigger only to the right side.

           -I can't be sure that "artboard 0" is always the one on the left (even if it should be like this), so the best way is to merge both of the artboards, but Im not sure it's possible by scripting.

           -Create a third artboard, whose coordonates are the same on left corners of left artboard, end the same on right corners of right artboard.

       

      I hope I've been clear, and that you can help me on that.

       

      Thank you all in advance !

        • 1. Re: artboard coordinate
          Muppet Mark Level 5

          This should create you a NEW artboard that encompasses all others regardless…

           

          #target illustrator
          
          superArtboard();
          
          function superArtboard() {
          
            app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
          
            var i, doc, artBds, supABd;
          
            doc = app.activeDocument;
          
            artBds = doc.artboards;
          
            supABd = artBds[0].artboardRect;
          
            for ( i = 1; i < artBds.length; i++ ) {
          
            if ( artBds[i].artboardRect[0] < supABd[0] ) { supABd[0] = artBds[i].artboardRect[0] }; // Left
          
            if ( artBds[i].artboardRect[1] > supABd[1] ) { supABd[1] = artBds[i].artboardRect[1] }; // Top
          
            if ( artBds[i].artboardRect[2] > supABd[2] ) { supABd[2] = artBds[i].artboardRect[2] }; // Right
          
            if ( artBds[i].artboardRect[3] < supABd[3] ) { supABd[3] = artBds[i].artboardRect[3] }; // Bottom
          
            };
          
            doc.artboards.add( supABd );
          
            app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS;
          
          };
          
          
          • 2. Re: artboard coordinate
            pixxxel schubser Level 5

            Hi PYLerayer,

            @Muppet Mark gives you the alternative nr.3

             

            Another variant:
            Enlarges the first artboard and removed the other.

            // ArtboardsMergeAllCompact.jsx
            // enlarges the first artboard and removes the other artboards
            // regards pixxxelschubser
            
            var aDoc = app.activeDocument;
            var AB = aDoc.artboards;
            var ABR = AB[0].artboardRect;
            
            for ( i = AB.length-1; i > 0; i-- ) {
                ABR[0] = (ABR[0] < AB[i].artboardRect[0]) ? ABR[0] : AB[i].artboardRect[0]; // Left
                ABR[1] = (ABR[1] > AB[i].artboardRect[1]) ? ABR[1] : AB[i].artboardRect[1]; // Top
                ABR[2] = (ABR[2] > AB[i].artboardRect[2]) ? ABR[2] : AB[i].artboardRect[2]; // Right
                ABR[3] = (ABR[3] < AB[i].artboardRect[3]) ? ABR[3] : AB[i].artboardRect[3]; // Bottom
               
                AB[i].remove();
                }
            AB[0].artboardRect = ABR;
            
            

             

            You also get a „superArtboard“ (like in Muppets Marks script) but in the end there is only one artboard in your document.

             

            Have fun

             

            • 3. Re: artboard coordinate
              PYLerayer Level 1

              Thank you guys, it works !

               

              I will come back to you if I have more questions.

               

              Bye

              • 4. Re: artboard coordinate
                PYLerayer Level 1

                Actually, this .jsx script is independant, which means that it perfectly works, but alone. The thing is that I would like to insert it in the pannel Action, because I have more actions to play in a particular order.

                 

                Do you know if this is possible and the way i have to do it ?

                 

                Thank you,

                PY

                • 5. Re: artboard coordinate
                  Muppet Mark Level 5

                  function startRant() {

                       Yes this is possible… But you are going to bash your head against the longest running ISSUE with AI…

                       You can use the insert menu item and add the script part to your action…

                       BUT this ONLY works per AI session… ARGH why has this NOT been addressed in 10 years…???

                       You will need to relink the script at each and every AI restart…

                  };

                   

                  The ONLY workaround at present is to use script as the main processor and call actions for the other parts…