9 Replies Latest reply on Sep 20, 2010 8:57 PM by Steven..

    [CS5 - JS] Object ID...

    Emanuele Radaelli

      Hi,

      I have a question about objects ID.

      Is the ID unique?

      I mean is it possible that 2 different objects (i.e. a layer and a color or a textFrame and a ParagraphStyle...) have the same ID?

      Is can't see any documentation about this.

       

      Thanks!

        • 1. Re: [CS5 - JS] Object ID...
          Steven.. Level 3

          The objectID is the internal way of identifying objects, better known as the UID in the SDK. Each type of objects has it's list, but different types like styles and colors etc... can certainly have the same number

          1 person found this helpful
          • 2. Re: [CS5 - JS] Object ID...
            Emanuele Radaelli Level 1

            Thanks Steven,

            that's what I was looking for.

             

            The problem is that I have to assign a unique ID to all InDesign objects, so I build a variable for every object where to store:

            1) The type of the object (i.e. "Layer" or "PStyle" or "Story"...);

            2) The InDesign ID (i.e. "201");

            3) A unique ID I create with a dedicated function (i.e. "4e985c-803a9d").

             

            I was thinking about building an array of arrays but I'm not sure this is the best way to do the trick...

            Do you have any suggestion?

             

            Thanks again.

            • 3. Re: [CS5 - JS] Object ID...
              [Jongware] Most Valuable Participant
              ... different types like styles and colors etc... can certainly have the same number ..

               

              Steven, how sure are you about that?

               

              Inside an InDesign file every single object sure has one, single, and unique ID. It's how ID keeps track of the position of each object inside the file. A stroke style such as "Thick-Thin-Thick" reports an UID of B009h, and "Solid" reports 5A29h, which occurs, for example, in data describing Footnotes (the "Solid" style of the separator line).

              • 4. Re: [CS5 - JS] Object ID...
                Emanuele Radaelli Level 1

                Thanks Jongware,

                but I'm a bit confused right now.

                I need to know if I should reference to objects with their unique ID... Is there something in the official documentation about ID in InDesign?

                I took a look also at IDML documentation but it confused me more. It looks like the "name" attribute in IDML is similar to the InDesign ID:

                 

                "A default name is used if an object in an InDesign document does not have a user-defined component name. The default name is generated by appending the object’s UID (an InDesign internal value) to its script object type. For example, the default name for a story with UID 0x1c8 is Story_uic8."

                 

                But from what I know objects ID are composed only by numbers...

                Thanks.

                • 5. Re: [CS5 - JS] Object ID...
                  [Jongware] Most Valuable Participant
                  ..  Is there something in the official documentation about ID in InDesign? ..

                   

                  No Not at all. The SDK mentions them, but doesn't really goes into where they come from. A lot of them get simply 'defined', and the rest is generated according to some internal system.

                   

                  For example, the default name for a story with UID 0x1c8 is Story_uic8

                   

                  I'm pretty sure that ought to be 1C8. The default notation for UIDs and their string representation is, as indicated by the 0x prefix, in hexadecimal. But for all intents and purposes, I'm not too sure you can create and assign new ids out of the blue. None of your 'own' ids should be used more than once (for instance, for a Spread and for a Story), and, even worse, InDesign has lots of ids pre-assigned to various objects (such as the built-in Stroke type I mentioned). There is no sure way to know if a random id -- say, 0x1966 -- isn't 'in use' already. (And I think prepending "Story" to "u1C8" was just to make the IDML slightly more human-readable.)

                   

                  That said: I'm pretty sure the IDML programmers knew this as well. Perhaps there is a 'private' id range that you can safely assign. If so, it must be mentioned somewhere in the IDML documentation. Hopefully someone over in the SDK forum knows more about this ...

                  • 6. Re: [CS5 - JS] Object ID...
                    Harbs. Level 6

                    They are hex numbers internally...

                     

                    Harbs

                    • 7. Re: [CS5 - JS] Object ID...
                      [Jongware] Most Valuable Participant

                      Sorry to correct you! -- but it's a common misconception, that 'computers work internally in hex'.

                       

                      Internally, they are bit patterns. These are usually interpreted as common numbers, so adding 1 to 19 always will yield 20. It's just that these numbers can be represented in decimal, but they can also be represented in hexadecimal (where adding 1 to 19 yields 1A). It's only a question of what's the most appropriate notation, per instance that you display a number from the computer memory (or a file) on screen.

                       

                      [ Hex is quite an appropriate notation for raw data, straight out of a file, when you don't know what each number represents:

                       

                      18 00

                       

                      -- what's this? The decimal value '24', or two bits set ,14 bits clear, or ASCII code 24?

                       

                      In the proper context, it's "UIColor:18", or the 1st internally defined UID color -- since this list happens to start at UID:18 --, which is defined as RGB(79,153,255), also better known under the name "Cyan".

                       

                      So if we know we're looking at a layer definition, this could indicate the layer color, and you would like to see it printed out as "Cyan". In other contexts, it's something entirely different, and may better be represented in hex. Or in decimal. ]

                      • 8. Re: [CS5 - JS] Object ID...
                        Harbs. Level 6

                        I did not mean they are literally hex numbers internally. Of course in machine code everything is 1s and 0s. "Represented as hex numbers in source code" would have been more correct...

                         

                        I have to remember to be careful how I say things around you...

                         

                        Harbs

                        • 9. Re: [CS5 - JS] Object ID...
                          Steven.. Level 3

                          From SDK Documentation

                          In InDesign, document files are represented internally as databases. (...) To store (...) objects in a database, a unique identifier (UID) is assigned to each (...) object. In the InDesign object model, UIDs (which are stored internally as 32-bit unsigned integers) are handles that are treated somewhat like pointers.(...) These UIDs are persistent across InDesign application sessions, so even after quitting and restarting InDesign, the UIDs stored in your documents continue to be valid.

                           

                          [Jongware] wrote:

                           

                          Steven, how sure are you about that?

                          The issue I was referring to, is that even though the document is a database with your info, the workspace is also a database with info. When referring to colors they may belong to the workspace, while styles may have to do with document. Being so, a style may have the same UID as a color.