15 Replies Latest reply on Aug 5, 2013 11:39 PM by Trevorׅ

    Slug Script...

    attil

      Does anyone have a script for a slug that they are willing to share. I suck at this scripting stuff, but want to learn.

      My needs are: Filename, Version #, Date Created, Date Modified, Colours used, Page Size, Proof output at %.

       

      Thanks in advance.

        • 1. Re: Slug Script...
          [Jongware] Most Valuable Participant

          (DAMN the Jive editor!! Starting over.)

           

          This script displays a dialog, filling in as much as possible. Sorry, the explanation was quite a bit longer, but DAMN the Jive Editor!!

           

          //DESCRIPTION:Slug fill-in
          // Jongware, 12-Sep-2009
          // Create a list of colors used
          allcolors_array = new Array;
          for (i=0; i<app.activeDocument.swatches.length; i++)
          {
            allcolors_array.push (app.activeDocument.swatches[i].name);
            for (j=0; j<app.activeDocument.unusedSwatches.length; j++)
              if (app.activeDocument.swatches[i] == app.activeDocument.unusedSwatches[j])
              {
                allcolors_array.pop();
                break;
              }
          }
          colorlist = allcolors_array.join(' / ');
          // Create dialog so you can adjust stuff
          myDialog = app.dialogs.add ({name:"Slug Fill-in",canCancel:true});
          today = new Date();
          with (myDialog)
          {
           with (dialogColumns.add())
           {
            staticTexts.add ({staticLabel:"Filename"});
            staticTexts.add ({staticLabel:"Version"});
            staticTexts.add ({staticLabel:"Created"});
            staticTexts.add ({staticLabel:"Modified"});
            staticTexts.add ({staticLabel:"Colors"});
            staticTexts.add ({staticLabel:"Page Size"});
           }
           with (dialogColumns.add())
           {
            var field1 = textEditboxes.add ({editContents:app.activeDocument.name, minWidth:200});
            var field2 = textEditboxes.add ({editContents:"1.0", minWidth:200});
            var field3 = textEditboxes.add ({editContents:today.toDateString(), minWidth:200});
            var field4 = textEditboxes.add ({editContents:today.toDateString(), minWidth:200});
            var field5 = textEditboxes.add ({editContents:colorlist, minWidth:200});
            var field6 = textEditboxes.add ({editContents:app.activeDocument.documentPreferences.pageWidth+" x "+app.activeDocument.documentPreferences.pageHeight, minWidth:200});
           }
          }
          if (myDialog.show() == false)
           exit(0);
          // Create slug frame
          slugframe = app.activeWindow.activePage.textFrames.add ();
          slugframe.geometricBounds = [ app.activeDocument.documentPreferences.pageHeight, 0, app.activeDocument.documentPreferences.pageHeight+app.activeDocument.documentPreferences.slugBottomOffset, app.activeDocument.documentPreferences.pageWidth];
          slugframe.textFramePreferences.verticalJustification = VerticalJustification.CENTER_ALIGN;
          slugframe.insertionPoints[0].justification = Justification.CENTER_ALIGN;
          slugframe.insertionPoints[0].fillColor = app.activeDocument.swatches.item("Registration");
          slugframe.contents = field1.editContents+" \u2022 "+field2.editContents+" \u2022 "+field3.editContents+" \u2022 "+field4.editContents+" \u2022 "+field5.editContents+" \u2022 "+field6.editContents;
          
          • 2. Re: Slug Script...
            [Jongware] Most Valuable Participant

            Now I've cooled off a bit, here is the slightly longer story.

             

            As you can see, the new text frame is positioned at (0, pageheight, pagewidth, pageheight + bottom slug height) -- in regular (lx,ly, rx,ry) coordinates (geometricBounds is a bit different). It needs absolute coordinates, and I am assuming the zero ruler point is at the left top of your document.

             

            The slug frame is created on the active page in your current viewing window; perhaps you'd like it to be placed on a master page, or on every single page of the document instead.

             

            As you can see, there is not really a good way to retrieve a 'creation date' -- unless you use a text variable for that! I'd have to look it up, but it is possible to create that and insert into the slug frame.

             

            As for 'version' -- how do you decide this? Perhaps the script could store its current 'version' number into the document, so you can update it by running the script. In that case, I'd think about adding a unique label identifier to the slug text frame, so you can clear it before updating the text.

             

            I forgot to add an output percentage edit field to the dialog, which is easily fixed -- but you need to fill in that text yourself. I don't think I could grab the value from anywhere.

             

            I set the text color of the slug frame to 'Registration', and its horizontal and vertical alignment to centered; if required, it's also possible to set a font and font size. And when I create a color list (by hand), I usually set the color of each name to that color -- that way, each plate only shows one color name.

            • 3. Re: Slug Script...
              attil Level 1

              Thanks for the script, but I keep getting errors in applescript. Am I doing

              this right?

               

               

               

               

              From: "[Jongware]" <forums@adobe.com>

              Reply-To: <clearspace-1393920936-504487-2-2244319@mail.forums.adobe.com>

              Date: Sat, 12 Sep 2009 11:31:18 -0600

              To: Attilio Lucchese <attil@sympatico.ca>

              Subject: Slug Script...

               

              //DESCRIPTION:Slug fill-in

              // Jongware, 12-Sep-2009

              // Create a list of colors used

              allcolors_array = new Array;

              for (i=0; i<app.activeDocument.swatches.length; i++)

              {

                allcolors_array.push (app.activeDocument.swatches+.name);

                for (j=0; j<app.activeDocument.unusedSwatches.length; j++)

                  if (app.activeDocument.swatches+ ==

              app.activeDocument.unusedSwatches[j])

                  {

                    allcolors_array.pop();

                    break;

                  }

              }

              colorlist = allcolors_array.join(' / ');

              // Create dialog so you can adjust stuff

              myDialog = app.dialogs.add ();

              today = new Date();

              with (myDialog)

              {

              with (dialogColumns.add())

              {

                staticTexts.add ({staticLabel:"Filename"});

                staticTexts.add ();

                staticTexts.add ();

                staticTexts.add ();

                staticTexts.add ();

                staticTexts.add ();

              }

              with (dialogColumns.add())

              {

                var field1 = textEditboxes.add ({editContents:app.activeDocument.name,

              minWidth:200});

                var field2 = textEditboxes.add ();

                var field3 = textEditboxes.add ();

                var field4 = textEditboxes.add ();

                var field5 = textEditboxes.add ();

                var field6 = textEditboxes.add

              ();

              }

              }

              if (myDialog.show() == false)

              exit(0);

              // Create slug frame

              slugframe = app.activeWindow.activePage.textFrames.add ();

              slugframe.geometricBounds = [

              app.activeDocument.documentPreferences.pageHeight, 0,

              app.activeDocument.documentPreferences.pageHeight+app.activeDocument.documentP

              r eferences.slugBottomOffset,

              app.activeDocument.documentPreferences.pageWidth];

              slugframe.textFramePreferences.verticalJustification =

              VerticalJustification.CENTER_ALIGN;

              slugframe.insertionPoints[0].justification = Justification.CENTER_ALIGN;

              slugframe.insertionPoints[0].fillColor =

              app.activeDocument.swatches.item("Registration");

              slugframe.contents = field1.editContents" \u2022 "field2.editContents+"

              \u2022 "field3.editContents" \u2022 "field4.editContents" \u2022

              "field5.editContents" \u2022 "+field6.editContents;

               

              • 4. Re: Slug Script...
                AdobeScripts Level 3

                attil wrote:

                 

                Thanks for the script, but I keep getting errors in applescript. Am I doing

                this right?

                 

                this is JavaScript - you need to save this script as SLUG.JSX

                 

                robin

                 

                www.adobescripts.co.uk

                • 5. Re: Slug Script...
                  [Jongware] Most Valuable Participant

                  So it is. I was so peed off by this editor I forgot my usual "copy-into-ESTK-and-save-as" stuff. Dziękuję, Robert!

                  • 6. Re: Slug Script...
                    AdobeScripts Level 3

                    [Jongware] wrote:

                     

                    So it is. I was so peed off by this editor I forgot my usual "copy-into-ESTK-and-save-as" stuff. Dziękuję, Robert!

                    you are welcome 

                     

                    robin

                     

                    www.adobescripts.co.uk

                    • 7. Re: Slug Script...
                      attil Level 1

                      Hey, Gents. Sorry for the long delay. The script keeps giving me an error in line one. Am i still doing something wrong?

                      • 8. Re: Slug Script...
                        AdobeScripts Level 3

                        you mean these lines ?

                         

                        From: "[Jongware]" <forums@adobe.com>

                        Reply-To: <clearspace-1393920936-504487-2-2244319@mail.forums.adobe.com>

                        Date: Sat, 12 Sep 2009 11:31:18 -0600

                        To: Attilio Lucchese <attil@sympatico.ca>

                        Subject: InDesign Scripting Slug Script...

                         

                        this is header of e-mail - you need to delete it and start script from:

                         

                        //DESCRIPTION:Slug fill-in

                         

                        robin

                         

                        www.adobescripts.co.uk

                        • 9. Re: Slug Script...
                          attil Level 1

                          this is what i get... see attached.

                          • 10. Re: Slug Script...
                            [Jongware] Most Valuable Participant

                            A javascript should be saved as plain text. It's your text editor -- TextEdit, probably --, that doesn't live up to its name and saves the document by default as RTF.

                             

                            Alternatively, use the ESTK Editor that comes with InDesign -- it doesn't have this particular flaw.

                            • 11. Re: Slug Script...
                              attil Level 1

                              You guys are awesome. Thank you!

                              • 12. Re: Slug Script...
                                attil Level 1

                                Wait, one more thing. Is there any way to make the script run everytime you save the file so i can update the info eg. version and colours???

                                • 13. Re: Slug Script...
                                  Davey J. Level 1

                                  so, is there a way to get the slug to show up on every page in the .indd file?

                                  • 14. Re: Slug Script...
                                    DixieChan

                                    Hello,

                                     

                                    I was hoping to extend this script by adding coloured boxes next to each Pantone used.

                                     

                                    Can someone point me in the right direction?

                                    • 15. Re: Slug Script...
                                      Trevorׅ Adobe Community Professional

                                      Maybe this will help you http://forums.adobe.com/message/5027707#5027707

                                      I hope to come out with my pro version of the script in about 2 or3 weeks but it's not exactly what you want.