17 Replies Latest reply on Feb 23, 2012 3:27 PM by kevinlesser73

    simple slug script

    kevinlesser73 Level 1

      im trying to create a simple bottom of document, slug for cs5 ID in applescript on 10.6.8

       

      within the slug should sit 3 words, 'one', 'two' 'three' each word on a separate line, not 1 continuous line. im struggling to understand how to position a text frame rather than one continuous line

       

      can anyone assist?

       

      kl73

        • 1. Re: simple slug script
          Muppet Mark Level 5

          tell application "Adobe InDesign CS5"

                    tell the active document

                              tell the first spread

                                        set slugText to make new text frame with properties ¬

                                                  {geometric bounds:{(item 3 of page 1's bounds), 0, ((item 3 of page 1's bounds) + 15), 30}}

                                        set contents of slugText to "one" & return & "two" & return & "three"

                              end tell

                    end tell

          end tell

           

          --adds it bottom left for me…

           

          tell application "Adobe InDesign CS5"

                    tell the active document

                              set a to document bleed bottom offset of document preferences

                              set b to slug bottom offset of document preferences

                              tell the first spread

                                        set c to item 3 of page 1's bounds

                                        set slugText to make new text frame with properties ¬

                                                  {geometric bounds:{(c + a), 0, (c + b), 30}}

                                        set contents of slugText to "one" & return & "two" & return & "three"

                              end tell

                    end tell

          end tell

           

          --some tabbing madness here… a little better but it does presume bleeds and slugs

           


           


          • 2. Re: simple slug script
            kevinlesser73 Level 1

            mark

             

            thanks, you make it look so easy! another question if i may?!!

             

            i have adapted;

            how can i put more space between each line of type and to format to an arial bold 10pt for example?? i tried to increase 15 and 30 figures but no change???, you can see ive added some text tags in replacement of one two three, the slug grame is not big enough now!!

             

            cheers, really appreciate assistance, whih country are you in?

             

             


             

             

            tell application "Adobe InDesign CS5"

                      tell the active document

                                tell the first spread

                                          set slugText to make new text frame with properties ¬

                                                    {geometric bounds:{(item 3 of page 1's bounds), 0, ((item 3 of page 1's bounds) + 15), 30}}

                                          set contents of slugText to "{{_es_signer_signatureblock}}" & return & "Qty:{{*comment1_es_signer}}" & return & "Invoiced to:{{*comment1_es_signer}}"

                                end tell

                      end tell

            end tell

             


            • 3. Re: simple slug script
              Muppet Mark Level 5

              This goes inside the tell spread block… after you set the contents… I wouldn't have guessed applied font

               

              set applied font of every paragraph of slugText to "Arial MT          Bold"

              set point size of every paragraph of slugText to 10

              set leading of every paragraph of slugText to 20

              • 4. Re: simple slug script
                kevinlesser73 Level 1

                im understanding the 'returns'! and im nearly there i think,

                 

                this code

                set applied font of every paragraph of slugText to "Verdana"

                                              set point size of every paragraph of slugText to 10

                                              set leading of every paragraph of slugText to 16

                 

                is only working on the 1st line of type for some reason mark?, i presume its because ive added 2 more returns? (see below), i need these extra 2 returns after 1st line as the tag in line 1 produces a rather deep box, also the text frame is way too small, i need to extend the handles on the box to make the type visible, is there a way to make the frame the width of the document?

                 

                thanks alot.

                 

                k

                 

                 

                tell application "Adobe InDesign CS5"

                          tell the active document

                                    tell the first spread

                                              set slugText to make new text frame with properties ¬

                                                        {geometric bounds:{(item 3 of page 1's bounds), 0, ((item 3 of page 1's bounds) + 15), 30}}

                                              set contents of slugText to "{{_es_signer_signatureblock}}" & return & return & return & "Qty:{{*comment1_es_signer}}" & return & "Invoiced to:{{*comment1_es_signer}}"

                                              set applied font of every paragraph of slugText to "Verdana"

                                              set point size of every paragraph of slugText to 10

                                              set leading of every paragraph of slugText to 16

                                    end tell

                          end tell

                end tell

                • 5. Re: simple slug script
                  Muppet Mark Level 5

                  Well you can do that in a couple of ways… Adding returns is going to give you blank paragraphs of 16pt leading… Or you could set the leading for each paragraph to suit…

                   

                  tell application "Adobe InDesign CS5"

                            tell the active document

                                      set a to document bleed bottom offset of document preferences

                                      set b to slug bottom offset of document preferences

                                      tell the first spread

                                                set c to item 3 of page 1's bounds

                                                set d to item 4 of page 1's bounds

                                                set slugText to make new text frame with properties ¬

                                                          {geometric bounds:{(c + a), 0, (c + b), d}}

                                                set contents of slugText to "{{_es_signer_signatureblock}}" & return ¬

                                                          & "Qty:{{*comment1_es_signer}}" & return ¬

                                                          & "Invoiced to:{{*comment1_es_signer}}"

                    --set applied font of every paragraph of slugText to "Arial MT Bold"

                                                set point size of every paragraph of slugText to 10

                                                set leading of every paragraph of slugText to 20

                                                set leading of second paragraph of slugText to 40

                                      end tell

                            end tell

                  end tell

                   

                  I just commented out the font swap line as don't have that loaded now… The box is page width from bleed offset to slug offset

                  • 6. Re: simple slug script
                    kevinlesser73 Level 1

                    excellent, i was getting errors but i worked that out, because slug on doc was not big enough

                     

                    is there a way i can automate a slug creation to fit also?

                     

                    scripting is awesome!!! i would love to learn more.

                     

                    thanks mark

                    • 7. Re: simple slug script
                      Mars_Man Level 1

                      Hi Muppet Mark,

                       

                      I've just been reading through this thread, and was wondering if you could help me. I'm looking to set up a script sort of along these lines, excpet that I would want the script to create a new indesign document and then add in a indesign snippet into the slug. The doucment sizes would vairey each time so the cordinates of the placed snippet would also change each time. I've been looking on line for some help on this as my scripting knowledge isnt that good. Do think it possible to do this?

                       

                      Sorry for tagging onto the topic, but you seem pretty clued up on the scripting side and its in the same area.

                       

                      Thanks

                       

                      Marsman

                      • 8. Re: simple slug script
                        Muppet Mark Level 5

                        Yes you can set both the slug and bleed offsets… They are read/write properties… As I stated the script as is was expecting these to be set but if they aren't then it could set them first… I mostly use new document presets where this can be defined…

                        • 9. Re: simple slug script
                          kevinlesser73 Level 1

                          something like this?

                          tell application "Adobe InDesign CS5"

                              tell document preferences of active document

                                  set document bleed bottom offset to "8p"

                                  set document bleed top offset to "8p"

                                  set document bleed inside or left offset to "8p"

                                  set document bleed outside or right offset to "8p"

                                  set slug bottom offset to "6p"

                                  set slug top offset to "0p"

                                  set slug inside or left offset to "0p"

                                  set slug right or outside offset to "0p"

                              end tell

                              tell the active document

                                  set a to document bleed bottom offset of document preferences

                                  set b to slug bottom offset of document preferences

                                  tell the first spread

                                      set c to item 3 of page 1's bounds

                                      set d to item 4 of page 1's bounds

                                      set slugText to make new text frame with properties ¬

                                          {geometric bounds:{(c + a), 0, (c + b), d}}

                                      set contents of slugText to "{{_es_signer_signatureblock}}" & return ¬

                                          & "Qty:{{*comment1_es_signer}}" & return ¬

                                          & "Invoiced to:{{*comment2_es_signer}}"

                                      set applied font of every paragraph of slugText to "Minion Pro"

                                      set point size of every paragraph of slugText to 12

                                      set leading of every paragraph of slugText to 20

                                      set leading of second paragraph of slugText to 40

                                  end tell

                              end tell

                          end tell

                           

                          dont work so i presume its wrong!

                          • 10. Re: simple slug script
                            Muppet Mark Level 5

                            Using snippets and events scripting are 2 things I have not done yet… It may be possible though… You may get more luck/answers if you are open to using JavaScript for this… ( more popular )

                            • 11. Re: simple slug script
                              Muppet Mark Level 5

                              Slugs and bleed can be set using 4 separate values or all 4 linked to one value… Your slug values are less than your bleeds… I would not expect that… A quickly hashed example… Uniform bleeds but but a deeper bottom slug

                               

                              tell application "Adobe InDesign CS5"

                                        tell the active document

                                                  tell document preferences

                                                            if document bleed uniform sizetrue then

                                                                      set document bleed uniform size to true

                                                                      set document bleed top offset to 5

                                                            end if

                                                            if document slug uniform sizefalse then

                                                                      set document slug uniform size to false

                                                                      set slug top offset to 10

                                                                      set slug inside or left offset to 10

                                                                      set slug right or outside offset to 10

                                                                      set slug bottom offset to 30

                                                            end if

                                                  end tell

                                                  tell the first spread

                                                            set c to item 3 of page 1's bounds

                                                            set d to item 4 of page 1's bounds

                                                            set slugText to make new text frame with properties ¬

                                                                      {geometric bounds:{(c + 5), 0, (c + 30), d}}

                                                            set contents of slugText to "{{_es_signer_signatureblock}}" & return ¬

                                                                      & "Qty:{{*comment1_es_signer}}" & return ¬

                                                                      & "Invoiced to:{{*comment1_es_signer}}"

                                --set applied font of every paragraph of slugText to "Arial MT Bold"

                                                            set point size of every paragraph of slugText to 10

                                                            set leading of every paragraph of slugText to 20

                                                            set leading of second paragraph of slugText to 40

                                                  end tell

                                        end tell

                              end tell

                              • 12. Re: simple slug script
                                kevinlesser73 Level 1

                                i need to study this... to understand the difference.

                                 

                                i changed the second return to a tab, due to aesthetics! but on a short width document e.g. a business card, the text frame is not wide enough, because it adheres to the page bounds, i tried to do the obvious, change bounds to other descriptions but wont work....?

                                • 13. Re: simple slug script
                                  kevinlesser73 Level 1

                                  to understand how to adjust a tab value would be good also.

                                  • 14. Re: simple slug script
                                    kevinlesser73 Level 1

                                    mark

                                     

                                    ive got around my issue by just repeating & tab & tab & tab!

                                     

                                    i dont understand what item 3 and item 4 is in this piece of code

                                     

                                    set c to item 3 of page 1's bounds, set d to item 4 of page 1's bounds

                                     

                                    i presume this is the key to making the text frame larger than page size?

                                     

                                    thanks

                                    • 15. Re: simple slug script
                                      Muppet Mark Level 5

                                      The bounds of an object are a 4 ltem list in AppleScript… So if I ask for the bounds of a page like so…

                                       

                                      tell application "Adobe InDesign CS5"

                                                tell the active document

                                                          get bounds of the first page

                                                end tell

                                      end tell

                                       

                                      It will return {0.0, 0.0, 296.999999999461, 209.999999999936} my default A4… So the script is just using the values of the 3rd and 4th items out of the list to do a little math with…

                                       

                                      As for your tabs then they belong to paragraphs so apply them there here is an example using 2

                                       

                                      tell application "Adobe InDesign CS5"

                                                tell the active document

                                                          tell the first text frame

                                                                    tell the first paragraph

                                        make new tab stop at beginning with properties ¬

                                                                                        {alignment:left align, position:10}

                                        make new tab stop at end with properties ¬

                                                                                        {alignment:left align, position:30}

                                                                    end tell

                                                          end tell

                                                end tell

                                      end tell

                                       

                                      tab, tab, tab, tut, tut I'll take that keyboard off ya…

                                       

                                       

                                       


                                      • 16. Re: simple slug script
                                        kevinlesser73 Level 1

                                        these wireless keyboards are no good!!!

                                         

                                        get the bounds thing, makes sense, not sure how to position your last code into existing?? see below

                                         

                                        im sure its something so simple to you experts!

                                         

                                         

                                         

                                        tell application "Adobe InDesign CS5"

                                            tell document preferences of active document

                                                set document bleed bottom offset to "1p"

                                                set document bleed top offset to "1p"

                                                set document bleed inside or left offset to "1p"

                                                set document bleed outside or right offset to "1p"

                                                set slug bottom offset to "8p"

                                                set slug top offset to "0p"

                                                set slug inside or left offset to "0p"

                                                set slug right or outside offset to "8p"

                                            end tell

                                            tell the active document

                                                set a to document bleed bottom offset of document preferences

                                                set b to slug bottom offset of document preferences

                                                tell the first spread

                                                    set c to item 3 of page 1's bounds

                                                    set d to item 4 of page 1's bounds

                                                    set slugText to make new text frame with properties ¬

                                                        {geometric bounds:{(c + a), 0, (c + b), d}}

                                                    set contents of slugText to "{{_es_signer_signatureblock}}" & tab ¬

                                                        & "Qty:  {{*comment1_es_signer}}" & return ¬

                                                        & "Invoiced to:  {{*comment2_es_signer}}"

                                                end tell

                                                tell the active document

                                                    tell the first text frame

                                                        tell the first paragraph

                                                            make new tab stop at beginning with properties ¬

                                                                {alignment:left align, position:10}

                                                            make new tab stop at end with properties ¬

                                                                {alignment:left align, position:30}

                                                        end tell

                                                    end tell

                                                    set applied font of every paragraph of slugText to "Arial"

                                                    set point size of every paragraph of slugText to 12

                                                    set leading of every paragraph of slugText to 20

                                                    set leading of second paragraph of slugText to 24

                                                end tell

                                            end tell

                                        end tell

                                        • 17. Re: simple slug script
                                          kevinlesser73 Level 1

                                          still struggling with the tab, tab, tab, however i position your code it doesnt alter the position of tabs??? ive prob got it in wrong place

                                           

                                          tell application "Adobe InDesign CS5"

                                                    tell document preferences of active document

                                                              set document bleed bottom offset to "1p"

                                                              set document bleed top offset to "1p"

                                                              set document bleed inside or left offset to "1p"

                                                              set document bleed outside or right offset to "1p"

                                                              set slug bottom offset to "14p"

                                                              set slug top offset to "0p"

                                                              set slug inside or left offset to "0p"

                                                              set slug right or outside offset to "10p"

                                                    end tell

                                                    tell the active document

                                                              set a to document bleed bottom offset of document preferences

                                                              set b to slug bottom offset of document preferences

                                                              tell the first spread

                                                                        set c to item 3 of page 1's bounds

                                                                        set d to item 4 of page 1's bounds

                                                                        set slugText to make new text frame with properties ¬

                                                                                  {geometric bounds:{(c + a), 0, (c + b), d}}

                                                                        set contents of slugText to "{{_es_signer_signatureblock}}" & return ¬

                                                                                  & "Qty:{{*comment1_es_signer}}" & tab ¬

                                                                                  & "Invoiced to:{{*comment2_es_signer}}"

                                                                        tell the first text frame

                                                                                  tell the first paragraph

                                            make new tab stop at beginning with properties ¬

                                                                                                      {alignment:left align, position:10}

                                            make new tab stop at end with properties ¬

                                                                                                      {alignment:left align, position:30}

                                                                                  end tell

                                                                        end tell

                                                                        set applied font of every paragraph of slugText to "Times"

                                                                        set point size of every paragraph of slugText to 12

                                                                        set leading of every paragraph of slugText to 60

                                                              end tell