Search code examples
gisarcobjectsarcmap

How do you get a unique id for a layer or generate one in Arcmap?


Is there a way in arcobjects to get a unique id for a layer? If you do a search by layer name there could be possible duplicates.

If there isn't a property is there a way to generate an id? I tried using the GetHash() but that didn't stay consistent.


Solution

  • It isn't pretty, but in the past I've appended a guid in the layer description. Something like this:

    <LAYER guid='a9843c88-3caa-4953-ad96-ca9990b410e9' revision='1' />
    

    I've got a DLL floating around that would slam these xml frags into each layer of an MXD (with enough cr/lf in front to scroll the xml fragment out of the layer description in ArcMap Layer Prop dialog) .

    There's a help file in the 7z file (documentation is sparse because I'm doing other things): http://code.google.com/p/umbriel/downloads/list