2 Replies Latest reply on Jul 24, 2014 11:39 AM by InMarketing

    How to add document size value to a slug info box?

    InMarketing

      Hey guys,

       

      I an using an apple script to fill out automatically my slug box information with the following script:

      Screen Shot 2014-07-23 at 3.57.25 PM.png

      set mgDate to do shell script "date '+%d/%m/%y'"

      tell application "Adobe InDesign CS6"

          tell active document

              set mgPath to file path as string

              set mgName to name

              set text item delimiters of AppleScript to ":"

              set mgShortName to text item 1 of mgName

              set text item delimiters of AppleScript to "_"

              set mgClient to text item 3 of mgShortName

              set mgCode to text item 1 of mgShortName

              set mgTypeDoc to text item 5 of mgShortName

              set mgRetailer to text item 4 of mgShortName

              set mgJobNumber to text item 2 of mgShortName

              set text item delimiters of AppleScript to default

               repeat with mgPage from 1 to count pages

                  set mgWidth to item 4 of bounds of page mgPage

                  set mgWidth to mgWidth as integer

                  set mgHeight to item 3 of bounds of page mgPage

                  set mgHeight to mgHeight as integer

                  set mgDimensions to ((mgWidth as string) & "x" & mgHeight as string) & "inches"

            set active page of layout window 1 to page mgPage

                  tell active page of layout window 1

                      try -- check to see that correct SLUG is on the page

                          set mgFrame to ((text frame 1 of group 1) whose label is "SLUG")

                      on error

                          try

                              set mgFrame to (text frame 1 whose label is "SLUG")

                          on error

                              display dialog "Your SLUG should be in place on every page." & return & return & "(Note : the correct SLUG has been given a script label to help with automation)"

                          end try

                      end try

                  tell table 1 of mgFrame

                          set contents of cell 2 of row 1 to mgCode

                          set contents of cell 6 of row 1 to mgClient

                          set contents of cell 4 of row 1 to mgDate

                          set contents of cell 8 of row 1 to mgTypeDoc

                          set contents of cell 2 of row 2 to mgJobNumber

                          set contents of cell 6 of row 2 to mgRetailer

                          set contents of cell 8 of row 2 to mgDimensions

                          set contents of cell 4 of row 3 to mgPage as string

                          if contents of cell 4 of row 2 is "#" then

                              set contents of cell 4 of row 2 to "1"

                          else

                              set contents of cell 4 of row 2 to (contents of cell 4 of row 2) + 1 as string

                          end if

                      end tell

                  end tell

              end repeat

             

          end tell

      end tell

       

      My concern is this script makes the document size values rounded up to the closest decimal. For exemple if I am doing a 8.5x11 in document and I run the script,

      I will get 9x11 in in my slug box information. So I am looking for how to get the exact value? How could I also fill out automatically the units? For example, Something i am using Inches and sometimes Pixels.

      My actual script just allows to use Inches.... How could I fix that?

       

      Thanks you so much for your help and sorry for my english!

       

      Vincent

        • 1. Re: How to add document size value to a slug info box?
          Mary Posner Level 3

          You're explicitly telling it to round when you coerce the height and width to integers. If you want decimals, leave it as is, without the coercion.

           

          The second item might be a bit trickier, since it's possible to have different settings for the horizontal and vertical rulers. You could easily capture the units each uses and use those to construct your mgDimensions variable, e.g.

           

            set mgHUnits to horizontal measurement units of view preferences

           

          ... but that's going to make the Dimensions statement a bit clunky, e.g. "8.5 inches x 11.0 inches".

           

          You might consider having the script prompt you to select a measurement unit at the top of the script, have it enforce that that's the unit being used for both rulers, and then get your dimensions.

          • 2. Re: How to add document size value to a slug info box?
            InMarketing Level 1

            Hey Mary,

             

            I have added some changes to the original applescript I found on internet but i amnot able to find out where I am supposed to change the copy....

            Could you please correct my actual script with the revised lines you have suggested?

             

            I would really appreciate if you can help me out.

             

            Thank you!!!