2 Replies Latest reply on Jul 2, 2008 10:37 PM by myDwayneSmith

    [AS] [CS2] Placing images in frames

    myDwayneSmith Level 1
      Hello,

      Thank you all for such a brilliant forum. In the past two weeks I've gone from knowing nothing about scripting to compiling two scripts which do exactly as I need thanks mostly to contributors to this forum.

      My question is about WHY my script works. I can understand most of the syntax I've been working with (sort of) but I can't get my head around this one....

      The script is based on one from the thread "[AS] Indesign CS - place image into existing frame" (thanks Matt McGregor and Shane Stanley).

      **begin script**

      -- Thanks to all Adobe Forums contributors for generously publishing sections of code which new users can use to build their own
      -- This version selects images from a specific folder
      -- Script needs to be altered to automatically select the relevant "eps files" folder

      tell application "Finder"
      set dsFolder to "Macintosh HD:Users:Design:Desktop:Scripting:8076707_Qld WC:eps files:"
      set dsPics to every item of folder dsFolder
      end tell

      tell application "Adobe InDesign CS2"
      set dsDocument to active document
      set dsLayer to layer 4 of dsDocument
      tell dsLayer
      set FrameNo to 1
      repeat with dsPicItem in dsPics
      place dsPicItem as alias on rectangle FrameNo of dsLayer
      fit rectangle FrameNo given content to frame
      set FrameNo to (FrameNo + 1)
      end repeat
      end tell
      end tell

      **end script**

      How does the script understand the term dsPicItem when it hasn't been defined?
      How does the script know to place one instance of each image (rather than, say, repeating the first image in every frame)?

      Thanks in advance,

      Dwayne Smith
        • 1. Re: [AS] [CS2] Placing images in frames
          sstanleyau Level 4
          On 3/7/08 1:46 PM, "myDwayneSmith" <member@adobeforums.com> wrote:<br /><br />> How does the script understand the term dsPicItem when it hasn't been defined?<br />> How does the script know to place one instance of each image (rather than,<br />> say, repeating the first image in every frame)?<br /><br />When you say "repeat with dsPicItem in dsPics", you're saying to put a<br />reference to the first item of dsPics into dsPicItem, then next time around<br />put the second item, and so on. It's just a shorter way of saying:<br /><br />repeat with i from 1 to count of dsPics<br />set dsPicItem  to item i of dsPics<br /><br />Sometimes it can cause problems (because of the way references work), so the<br />"longer" way is a better habit to get into.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
          • 2. Re: [AS] [CS2] Placing images in frames
            myDwayneSmith Level 1
            Thanks for your succinct reply Shane.

            It's great to have someone help with navigating through this new, complex language.

            I will certainly be integrating your 'longer' (but safer) code into my scripts.

            Have a good one,

            Dwayne Smith