9 Replies Latest reply on Oct 16, 2012 1:04 AM by digisli

    Looking for script: Compound path, Set B&H, Fit, Export PNG, Next Image.

    digisli

      Hello,

       

      I am looking for an script to automate.

       

      run script on all open AI files;

      - Select all

      - Make Compound Path

      - Set B or H to 600 pixels maximum, proportional

      - Fit to Artwork Bounds

      - Export to PNG, Normal 150ppi, Transparant, Anti al. supersampling

      - Close Window

      - Not Save

       

      - Next image until end

       

      Thanks and Kind Regards,

      digisli

        • 1. Re: Looking for script: Compound path, Set B&H, Fit, Export PNG, Next Image.
          [Jongware] Most Valuable Participant

          Are you looking for an existing script (unlikely, given your list of commands), help with getting started to write your own, or a total custom script, preferably written for free?

          • 2. Re: Looking for script: Compound path, Set B&H, Fit, Export PNG, Next Image.
            digisli Level 1

            Looking for a free script. If it's existing that's all right. Perhaps (you) someone can help me to write one.

            Combination of existing & custom don't care.

             

            Its also oke if :

            run script on all open AI files;

            - Select all

            - Make Compound Path

            - Export to PNG, Normal 150ppi, Transparant, Anti al. supersampling

            - Close Window

            - Not Save (or save different folder)

             

            - Next image until end

            • 3. Re: Looking for script: Compound path, Set B&H, Fit, Export PNG, Next Image.
              Muppet Mark Level 5

              You can't export to 150dpi all script exports are 72dpi except photoshop file format… There appears no conditions to this are you sure you even need a script won't an action ran in batch mode do this?

              • 4. Re: Looking for script: Compound path, Set B&H, Fit, Export PNG, Next Image.
                digisli Level 1

                Yes Muppet, I have figured it out. It can only be 72dpi.

                I have changed the Adobe sample .jsx file "open documents export to flash" to my own export to PNG24.

                It export now but not yet make a compound path!

                 

                Also i've got 2 png files for each open .ai document. One is 0 kb and the other is the good one.

                 

                 

                /**********************************************************

                 

                 

                ADOBE SYSTEMS INCORPORATED

                Copyright 2005-2006 Adobe Systems Incorporated

                All Rights Reserved

                 

                 

                NOTICE:  Adobe permits you to use, modify, and

                distribute this file in accordance with the terms

                of the Adobe license agreement accompanying it. 

                If you have received this file from a source

                other than Adobe, then your use, modification,

                or distribution of it requires the prior

                written permission of Adobe.

                 

                 

                *********************************************************/

                 

                 

                /**          Exports every document open in Illustrator

                          as a PNG file in a user specified folder.

                */

                 

                 

                // Main Code [Execution of script begins here]

                 

                 

                // uncomment to suppress Illustrator warning dialogs

                // app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

                 

                 

                try {

                          if (app.documents.length > 0 ) {

                 

                 

                                    // Get the folder to save the files into

                                    var destFolder = null;

                                    destFolder = Folder.selectDialog( 'Selecteer een map voor PNG-bestanden.', '~' );

                           

                                    if (destFolder != null) {

                                              var options, i, sourceDoc, targetFile; 

                                              

                                        // Get the PNG export options to be used.

                                              options = this.getOptions();

                                        // You can tune these by changing the code in the getOptions() function.

                              

                                        for ( i = 0; i < app.documents.length; i++ ) {

                                                  sourceDoc = app.documents[i]; // returns the document object

                 

                                                  // Get the file to export the document as png into

                                                        targetFile = this.getTargetFile(sourceDoc.name, '.ai', destFolder);

                 

                                                        // Export to png

                                                        sourceDoc.exportFile(targetFile, ExportType.PNG24, options);

                                              }

                                              alert( 'Documenten geÎxporteerd als PNG' );

                                    }

                          }

                          else{

                                    throw new Error('Er zijn geen documenten geopend!');

                          }

                }

                catch(e) {

                          alert( e.message, "Script Alert", true);

                }

                 

                 

                /** Returns the options to be used for the generated files.

                          @return ExportOptionsFlash object

                */

                function getOptions()

                {

                          // Create PNG export options

                          var options = new ExportOptionsPNG24();

                          // See ExportOptionsPNG in the JavaScript Reference for available options

                 

                          // Set the options you want below:

                 

                          // For example, ....

                          // ...;

                 

                          return options;

                }

                 

                 

                /** Returns the file to save or export into.

                          @param docName the name of the document to be saved or exported

                          @param ext the extension the file extension to be applied

                          @param destFolder the output folder

                          @return File object

                */

                function getTargetFile(docName, ext, destFolder) {

                          var newName = "";

                 

                 

                          // if name has no dot (and hence no extension),

                          // just append the extension

                          if (docName.indexOf('.') < 0) {

                                    newName = docName + ext;

                          } else {

                                    var dot = docName.lastIndexOf('.');

                                    newName += docName.substring(0, dot);

                                    newName += ext;

                          }

                 

                          // Create the file object to save to

                          var myFile = new File( destFolder + '/' + newName );

                 

                          // Preflight access rights

                          if (myFile.open("w")) {

                                    myFile.close();

                          }

                          else {

                                    throw new Error('De toegang is geweigerd');

                          }

                          return myFile;

                }

                 

                What is the difference between action/batch mode and scripting?

                If an action/batch mode also works than its fine to me. But how can i make a action or batch script file?

                 

                I just want to change many graphic files to png. without changing by hand.

                 

                thanks.

                digisli

                • 5. Re: Looking for script: Compound path, Set B&H, Fit, Export PNG, Next Image.
                  Muppet Mark Level 5

                  Actions are a recordable ( step by step ) process in AI and PS… You go through the sequence of events while recording… Once recorded you can call back the sequence to run over multi-files using batch mode… The difference is script can handle conditional logic… For example if layer exists do this otherwise do something else. Actions just try perform the steps. So you need to know everything required is in the files… Actions are a standard palette of the app GUI… You will be better off googling AI actions or asking in the general forum we mostly just script here… This is the palette and batch is bottom of the flyout-menu ( little arrow )

                   

                  Screen shot 2012-10-09 at 21.04.12.png

                  • 6. Re: Looking for script: Compound path, Set B&H, Fit, Export PNG, Next Image.
                    digisli Level 1

                    Yes thanks Muppet. I have found out the actions! (like PS, just forgot)

                    This works almost....

                     

                    I just need to resize my artwork to the arboard size.

                    for example my artboard will be all 600x600 pix.

                    i want to resize my artwork to that max. size of 600x600 proportional.

                    So if the artwork is 436x630 it will resize to 415x600

                     

                    But how can i make fit the artwork to the artboard size? with actions or scripts?

                     

                    thanks

                    • 7. Re: Looking for script: Compound path, Set B&H, Fit, Export PNG, Next Image.
                      digisli Level 1

                      I write an action to change the artboard size to the artwork, make compounts and export. This action i can batch al lot of images at once.

                       

                      How can i make an action or script to make the artwork size of the artboard?

                       

                      thanks.

                      • 8. Re: Looking for script: Compound path, Set B&H, Fit, Export PNG, Next Image.
                        jessevictoor Level 1

                        This one helped for me:

                         

                         

                        var doc = app.activeDocument;

                        doc.artboards[0].artboardRect = doc.visibleBounds; //cropping the artboard to the illustration size

                         

                        maybe it's helpful

                        • 9. Re: Looking for script: Compound path, Set B&H, Fit, Export PNG, Next Image.
                          digisli Level 1

                          I found that you can easy to run a action with: put menu-option and then type in "fit to artboard bounds". With this you can also run a batch.

                           

                          Thanks anyway.