3 Replies Latest reply on Nov 19, 2015 6:56 AM by Zantcor

    Scripting Languages, and numbering artboards

    Zantcor

      Hello fellow scripters,

       

      First Question:

      I know that the scripts support Java, and I remember it supporting Basic but what other languages can I script in?  Can I have the bulk of the script in Java then have parts in SQL?

       

      Second Question:

      I know how to make a script write text to an layer, and position using the (x,y) location but if I have multiple Art boards? I need to do the following;

       

      Check for total number of art boards //Some files have 2 others have 3 and very few will have 4.

      Take the art boards number, not the name and print it in the lower left (1,1) from the bottom.

       

      I would need to run this batch on a folder that has sub folders of sub folders.  They are all .ai or .pdf files and there are about 2k files.  I've got about 2-3 months to do this but I wanted to write the script now so that I can have it done, this way I can run it on chunks of the files at a time.

       

      I've never made a batch script, and I've never had to write a script that changes between art boards.  I need to know how to tell Illustrator to Select an art board, I can create the for loop cycling through all the art boards and then I can tell it to save but how do I tell it to grab the next file in the folder and repeat?

        • 1. Re: Scripting Languages, and numbering artboards
          CarlosCanto Adobe Community Professional & MVP

          check File System section in the Tools Guide.

           

          first get a reference to a folder

           

          var mydesk = Folder.desktop;
          
          

           

          then to get the files in the folder

           

          var files = mydesk.getFiles (/\.(ai|pdf)$/i); // returns an array of files
          
          

           

          then loop thru the files and do your thing

           

          loop {
              var file = files[i];
          
          
          • 2. Re: Scripting Languages, and numbering artboards
            williamadowling Level 4

            to print text to each artboard, you can use the below function. i'd just set a variable for the text to print so it can be easily changed if need be.

             

            I hope this is helpful.

             

            function printToArtboards(){
                var docRef = app.activeDocument;
                var artboards = docRef.artboards;
                var layers = docRef.layers;
                app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM;
            
            
                for(var a=0;a<artboards.length;a++){
                    artboards.setActiveArtboardIndex(a);
                    var theAB = artboards[0].artboardRect;
                    var text = layers[0].textFrames.add();
                    text.contents = 'This is artboard ' + (a+1);
                    text.left = 1;
                    text.top = (theAB[3] - theAB[1]) + text.height + 1;
                }
            }
            printToArtboards();
            
            • 3. Re: Scripting Languages, and numbering artboards
              Zantcor Level 1

              Thank you both, this will be very handy in the future for all my scripting needs.

               

              Many Thanks!