Finding Unique object with ID?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 06 June 2008   #1
Finding Unique object with ID?

Is there any way to get an object id?

The way I normally find objects in the scene is by the name. However this doesn't work if you have objects which identical names.

Example scene:
$Box
$Box
$Box

Now, If I write $Box what box will I actually select?
Ideally I would like to be able to write something like
objectID=$Box.id
select ObjectID --selects the box in the line above

Is this possible? I remember that the ids exist in c++ sdk

/Andreas
__________________
Rare - Lead VFX Artist
 
Old 06 June 2008   #2
There's two methods... this one has existed for a long time:

   myHandle = $.inode.handle -- returns a node handle, integer
   myNode = maxOps.getNodeByHandle myHandle -- returns the node given the handle
   

But if you plan on doing any merging, x-ref'ing, etc. this method is unsafe, as the handle changes.

And this one is 'new' and applies to non-nodes as well (materials, controllers, etc.)

   myHandle = getHandleByAnim $
   myNode = getAnimByHandle myHandle
   


[strike]I'd imagine the same problem applies to this system, but I haven't tested [/strike]

UNGHk... nevermind that last one; the handles there change even when you load the same scene - woop

So your best bets if you really want a plausibly-unique way to identify your objects would be....
A. a scripted plugin or custom atrribute block with a nodeTab or maxwrapperTab in which you can drop the objects
B. a persistent global variable that points to the appropriate object(s)
C. setting a 'unique' ID on the object somewhere.. for example in user properties, or appData; and then iterating over the scene to find them again.
D. <Insert further options here>

Edit: - > =, '' > =. eek.

Last edited by ZeBoxx2 : 06 June 2008 at 04:49 PM.
 
Old 06 June 2008   #3
Thanks man! Very good reply.
Setting user properties works, but is slow cpu wize and is quite tedious.
I think I will try the node.handle. Seems like it should work. I'm not dealing with any merges as far as I know

Trying it out now!
/Andreas
__________________
Rare - Lead VFX Artist
 
Old 06 June 2008   #4
We beat modelers with bad naming conventions.... ohhh.. did I just write that?

There's also the UniqueName if you can torerate numbers on the end of your names, then collect with a $'Box*'

If you want to personally manage them, then Appdata is probably best.. It's lightning fast.
I've used bit.IntToHex and bit.HexToInt to reduce the data amount I'm storing on the object to just four characters per node. AppData only stores string data.
__________________
Keith R Morrison
www.focus360.com

XP Pro x64, Win 7 - Max 2009, Max 2013 - Vray 2.30.01 - Backburner (uhg)

Last edited by Kramsurfer : 06 June 2008 at 04:49 PM.
 
Old 06 June 2008   #5
and make sure to use <node>.inode.handle ; as there are some objects (I'm looking at you, teapot) that have a .handle parameter of their own
 
Old 06 June 2008   #6
Originally Posted by Kramsurfer: We beat modelers with bad naming conventions.... ohhh.. did I just write that?


Hehe, well this is for characters and their bones dont have unique names so I can't really blame the artists here
/Andreas
__________________
Rare - Lead VFX Artist
 
Old 06 June 2008   #7
but... bones do have unique names! L Tibia!

That said - given how much of max relies on unique names for a lot of things, it's always baffled me that it doesn't enforce this... even if it's just a cosmetic enforcement that could be toggled off in the preferences.

Actually... one could script this..
*runs*
 
Old 06 June 2008   #8
I find myself using custom attributes, like Richard was saying. Pump in a tag to identify your objects, like "myTag". Then when you want to retrieve it:
for o in objects where (isProperty o.baseObject #myTag) == true do voodoo

Been working good so far :P
__________________
www.jasonlabbe3d.com
 
Old 06 June 2008   #9
Just about every thing that I build gets put into a maxObjectTab in a container modifier so I can seach the maxObjectTab for what I'm looking for. All I need to do is collect all the modifiers with (getClassInstances myContainerMod) and then iterate through all the parts for each group of objects in the tab. The container will have a name property as well that I can check for as well as a unique ID to match it agaist. Yep, I've worked with those modelers as well
__________________
Paul Neale
http://paulneale.com
 
Old 06 June 2008   #10
Originally Posted by ZeBoxx2: but... bones do have unique names! L Tibia!

Really? All the bones I see have non-unique names.

Originally Posted by ZeBoxx2: That said - given how much of max relies on unique names for a lot of things, it's always baffled me that it doesn't enforce this... even if it's just a cosmetic enforcement that could be toggled off in the preferences.

Yea you are right. It's strange, maybe there is a reason, maybe. Personally I like when they just index the names. We are building our own super big editor and I spent quite some time making sure that all the names are unique. Can be a bit of a pain though, you can model several people at one scene and then it can be tricky to make sure everything is unique..

/Andreas
__________________
Rare - Lead VFX Artist
 
Old 06 June 2008   #11
Originally Posted by f97ao: Really? All the bones I see have non-unique names.

Well, reall world bones, at least
http://en.wikipedia.org/wiki/List_o..._human_skeleton
( prepend with L or R where appropriate )
 
Old 06 June 2008   #12
It's a bit much to manage, but all of our rigged people have names. So we can just say I want to see Robert and Sally walking across the balcony. We don't have any hero 3D people, green screen for anything over 3-5% of the screen. Their rig naming corresponds to the person.... We haven't gotten to last names yet, but some of them are pretty funny...if you've lotsa people you need to name, there are some pretty interesting random name generation website out there...
__________________
Keith R Morrison
www.focus360.com

XP Pro x64, Win 7 - Max 2009, Max 2013 - Vray 2.30.01 - Backburner (uhg)
 
Old 06 June 2008   #13
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 11:08 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.