3 Replies Latest reply on Apr 2, 2009 7:15 AM by Peter Bossens

    Reference to object by ID (Applescript)

    Peter Bossens
      Applescript - InDesign CS2
      I would like to check some attributes of an object within a document from which I know the ID.
      How can I reference to this object using applescript?

      Suppose the ID is "3102", I would expect someting like:

      set myObject to item id 3102
      if name of fill color of myObject is .... then ...
      or:
      select myObject ....

      ...but this does not work! Any suggestions?

      Thanks,
      Peter
        • 1. Re: Reference to object by ID (Applescript)
          Dirk Becker  Level 4
          The class of objects addressed by ID is not checked - probably a minor bug. Most of these IDs (except XML elements) are unique across the classes. You can take advantage of that by using any class. The resulting object will have the correct class anyway.

          I would prefer to suggest you use some generic base class instead, but "Object" does not work.


          tell application "Adobe InDesign CS4"

             tell active document

                get id of page 1

                -- 190

                get class of character style id 190

                -- page

                get side of page id 190

                -- right hand

                get side of character style id 190
                -- right hand

             end tell

          end tell



          Dirk
          • 2. Re: Reference to object by ID (Applescript)
            Level 1
            Hi Peter,

            In addition to what Dirk said (thanks, Dirk!), I'd point out that "item" does not refer to anything in your example. Something like this, on the other hand, should work (provided that the object being addressed through the "tell" block contains page items):

            set myObject to page item id 3102
            

            Thanks,

            Ole
            • 3. Re: Reference to object by ID (Applescript)
              Peter Bossens Level 1
              Olav, Dirk, thanks a lot, it works!
              In my tests, I used "item id" instead of "page item id".
              From the answer of Dirk, I learned how to get the side of the page, also something I was searching for!

              Peter