3 Replies Latest reply on Jun 9, 2009 5:03 AM by penyfai

    Applescript to add multiple assets to INDL

    penyfai Level 1

      Hi

      I'm having problems writing an applescript that will take an item (or all items) on a page and add it/them to the Indesign library. I can get all graphic elements associated to an advert ID (eg: advert name 12345678, has 6 associated graphics named 12345678_*) and I can place them onto the page. I cannot then add these to the the library that has been created by the same script (12345678_library.indl).

       

      I've tried (snippet):

       

      set graphiclist to ""

      set graphicpath to (standardgraphicpath & lastdigits & ":")

      set graphicnumber to (count of files in folder graphicpath)

      set graphiclist to (name of every file in folder graphicpath where name contains adCID) as list

      repeat with i from 1 to number of items in graphiclist

      set graphicname to item i of graphiclist

      set fullgraphic to (graphicpath & graphicname)

      tell application "Adobe InDesign CS3"

      try

      set mypage to page 1 of spread 1 of active document

      tell mypage

      set placedgraphic to place fullgraphic

       

      tell document 1

      set activegraphic to item 1 of mypage

      set addgraphic to store graphiclib using activegraphic

      end tell

      end tell

      on error

      activate

      display dialog ("Had a problem with graphic " & graphicname)

      end try

      end tell

      --tell lib to get graphic and add to library

       

       

       

      end repeat

       

      I contstantly get a the error "Had a problem with graphic " & graphicname after the pictures are placed on the page

       

      I don't mind if we can make use of "Add items of page 1 as separate objects" as I can place all images successfully.

       

      Can someone please tell me where I'm going wrong - I think my head is about to explode!

       

      Thanks in anticipation

        • 1. Re: Applescript to add multiple assets to INDL
          sstanleyau Level 4

          You're trying to use the "store" command inside a "tell document" block -- that block is unnecessary anyway, so remove it and try again.

           

          --

          Shane Stanley <sstanley@myriad-com.com.au>

          AppleScript Pro Sessions <http://scriptingmatters.com/aspro>

          • 2. Re: Applescript to add multiple assets to INDL
            penyfai Level 1

            Thanks for that Shane, but for some reason the script is reporting that it can't get item 1 of page 1 of spread 1.

             

            I can't see why not, there's only one item on the page, plus the library panel that is open.

             

            Have I moved the store line to the wrong place?

             

            repeat with i from 1 to number of items in graphiclist

            set graphicname to item i of graphiclist

            set fullgraphic to (graphicpath & graphicname)

            tell application "Adobe InDesign CS3"

            try

            set mypage to page 1 of spread 1 of active document

            tell mypage

            set placedgraphic to place fullgraphic

            end tell

            on error

            activate

            display dialog ("Had a problem with graphic " & graphicname)

            end try

            set activegraphic to item 1 of page 1 of spread 1

            set addgraphic to store graphiclib using activegraphic

            end tell

             

            end repeat

            • 3. Re: Applescript to add multiple assets to INDL
              penyfai Level 1

              HI again Shane

               

              I got to think about the item issue. I was picking activegraphic as item 1 etc.

               

              I has now worked by simply using placedgraphic, as it holds all of the properties for the asset I needed to store.

               

              But thanks for the help, I was going further and further down a blind alley, but you turned me around and showed me the light.

               

              Cheers

              Andrew