Notifications
Clear all

[Closed] Unique object identification?

Hi,
as in max objects can have the same name, is there a way to uniquely identify an object? Some attribute I could read out or access somehow?

Thanks.

6 Replies
 Nam

I think what you are looking for is “handle”? Like $.handle.
Hope this helps,
–Nam

 PEN

There is an id number but this isn’t very useful as it changes when objects are merged into the scene. Where are you referencing these objects from? The best method to deal with collecting objects is to use a CA def or scripted plugin with a maxObjectTab array added where you can store weak references to the nodes that you need. Knowing what you are trying to do can help give me a better idea of what is best for you.

 S-S

Hi Lena. I haven’t used handle that much, but it should do what you need:


       -- select first teapot with name "teapot" manually... then evaluate the line under...
       firstteapot = $.inode.handle 
       
       -- select second teapot with name "teapot" manually... then evaluate the line under...
       secondteapot = $.inode.handle
       
       select (maxOps.getNodeByHandle firstteapot) -- will select first teapot
       select (maxOps.getNodeByHandle secondteapot)  -- will select second teapot
       
Hope this helps.

EDIT:
Paul:
I using handle reliable way? I tested it with merge too right now, it seems to give same handle number after merge? But like i said, haven’t used it nearly at all.

Might want to review the previous thread on this subject:
http://forums.cgsociety.org/showthread.php?f=98&t=608572

Looks like inode.handle (not just .handle) may not be unique if you merge/etc.

The only way that I know of to get a unique identifier that sticks with the object is by setting one up on the object yourself – either appData or a Custom Attributes block will do – concatenating the results of two genClassID() runs should give more than sufficiently unique results.

Thank you all for your suggestions. Based on your comments, I belive now for what we need to do, including Xrefs and maybe merging, the only “waterproof” solution is something like custom attributs.

 PEN

Handle is what I meant when I said ID. not reliable at all.