MObject unique ID's

378 views
Skip to first unread message

Mark Jackson

unread,
Oct 31, 2014, 7:07:15 AM10/31/14
to python_inside_maya
Hi all, 

I'm revisiting the Red9_Meta caching setup and am looking at the possibility of using the MObjectHandles hashID as a key in the MetaCache that I build up, currently I store the key as the dag path which is obviously not optimal. The cache saves any object being instantiated twice by the factory class and speeds things up considerably.

However, reading through the docs it seems that the hashID isn't actually unique, from the api docs:

"The returned hash code is not unique: several internal Maya objects may return the same code. However different MObjectHandles whose MObjects refer to the same internal Maya object will return the same hash code."

Can anybody shed any light on this, am I barking up the wrong tree here?

cheers

Mark

-------------------------------------
Mark Jackson
CEO / Technical Director
red9consultancy.com

Justin Israel

unread,
Oct 31, 2014, 7:36:50 AM10/31/14
to python_inside_maya
Sounds like what you want to do is cache on the hash code combined with a type identifier, since seems a hash code may not be unique across different types.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAGQH2FFG-jF%3DO6qtyPxwWp5jno%3DCk%3D5cJie9uaro7RpoC7p_SA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

David Moulder

unread,
Oct 31, 2014, 7:51:12 AM10/31/14
to python_inside_maya
Hi Mark,

Hows things?

I think the MObjectHandle is returning the its MObject.__hash__() and as 2 MObjectHandles can point to the same MObject you'll get the same uuid.

-Dave

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAGQH2FFG-jF%3DO6qtyPxwWp5jno%3DCk%3D5cJie9uaro7RpoC7p_SA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Mark Jackson

unread,
Oct 31, 2014, 8:57:42 AM10/31/14
to python_inside_maya
yeah, that's pretty much what I thought, just checking before I ditch the idea, if I'm going to be checking the hashID against the node Type in-order to extract a matching key from the dict then I may as well just revert to the system I had. Not that big a hit to re-instantiate the node if somebodies renamed it, the cache just updates itself.

As for things, yeah, bloody busy at the moment, Red9 is getting a lot of interest and we're already booked solid till well into December doing facial systems for a TV commercial, that and talking to a lot of games and pre-viz companies about pipelines. How about yourself Dave, been a long time!

Mark


For more options, visit https://groups.google.com/d/optout.



--

David Moulder

unread,
Oct 31, 2014, 9:22:45 AM10/31/14
to python_inside_maya
Still at Activision doing pipelines too, worked on pretty much most of the resent titles in some capacity, but mostly writing dcc pipeline tools, instructing in best practices, then the occasional flash, scaleform, actionscript, animation rigging, vfx, nuke thrown in.  Now we're working with pretty big external partners, who you'd think would have well oiled pipelines, but they still have room to improve.  So there's loads of work out there for you, that's for sure.  I'm still using the metadata system of old.  I see you've adapted a version of it in red9 as well.

If you want a constant uuid you could just write one into every meta node on construction and store it in your instance cache.  However if you dynamically changing the meta type like the old batch system you'd need to throw away the uuid in the cache.  Obviously metaNodes get deleted cache gets invalid, blar, blar.

-Dave



For more options, visit https://groups.google.com/d/optout.

Mark Jackson

unread,
Oct 31, 2014, 9:34:46 AM10/31/14
to python_inside_maya
yeah, I've spent the last 2 years writing the MetaData module and pretty much all of our pipeline is based on it in some form or another. Pretty much regrounded from scratch but keeping the factory aspects of the Eurocom setups, just a nice way of doing it via the mclass attrs. Modified all the behaviour to fit how we work here, making it easier to add and manage attrs and walk netwroks etc. But there's lots of expansion going on to the systems now that Red9 is a business and we have clients paying for this stuff!

There's already an ID on the nodes which I guess I could cache against, or yes, add a UID, but surprised that the MObject stuff didn't give me this in the first place.


For more options, visit https://groups.google.com/d/optout.

Marcus Ottosson

unread,
Nov 13, 2014, 5:19:11 AM11/13/14
to python_in...@googlegroups.com
Was looking up on this too, and found some more discussion about it here (albeit from 2008).

If I'm understanding your needs correctly, Mark, you're looking to uniquely, and immutably identify nodes in Maya? I'd like for this too, but it seems things haven't changed about this since that CGTalk thread, does anyone have any more info on this?

Adding an attribute is one way, but it eliminates the possibility of building for a generic Maya scene, as opposed to one that has been built with the tool in mind so that nodes can have been given UIDs in the first place.

Mark Jackson

unread,
Nov 13, 2014, 6:10:39 AM11/13/14
to python_inside_maya
Hi Marcus, thanks for the link, seems to re-enforce everything I've found so far, might ping the devs a mail, see if there's been any movement on this front in the api since that post. 

I've been digging too, and am still not satisfied with any of the solutions. MObjectHandles not being unque puts that out of the question. Adding a UUID to the nodes is great as it means everything is unique, except if you duplicate that node, you now have 2 nodes with the same UUID as I store it on the attrs of the node. At the moment the Cache is looking at the UUID and using that as the key in the cache, so what I'm thinking is that I change the UUID on the node everytime it gets added to the cache itself, so the cache adds the data and is responsible for it. Now this works as it means any nodes being added to the cache are always unique, until you bloody duplicate the damn node. I'm thinking of hooking to the callback on duplicate, but then there's bound to be more instance where this breaks so it doesn't seem the best option.

I can't believe there's not a simple solutions that's blatantly obvious for this, any more insights guys?


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

David Moulder

unread,
Nov 13, 2014, 2:53:51 PM11/13/14
to python_inside_maya
Hi Mark and Marcus.  The MAsset code I wrote managed uuids on duplicate callbacks.  You could re-use / re-factor that.  Worked throughout GoldenEye without any issues.

Also the cool thing about that uuid was I could add several nodes to the same uuid and treat them as one MAsset,  In effect Maya's containers, without the bugs at the time.  If for any reason the metaData connections are lost then you have the uuids to match them back up.

I'd prefer an alternative though!

 


For more options, visit https://groups.google.com/d/optout.



--

Mark Jackson

unread,
Nov 14, 2014, 4:55:58 AM11/14/14
to python_inside_maya
So I'm going for the UUID idea, but going to reset it each time the node gets cached, that way when referencing files the minute that node hits the cache the UUID is updated and becomes unique regardless of referencing. Just the node duplicate issue which I'll use the callback mechanism, I was looking at that on Monday as a possible hack. I also pinged Engineering about this so be interesting to see their response.

thanks

mark


For more options, visit https://groups.google.com/d/optout.

Marcus Ottosson

unread,
Nov 14, 2014, 4:59:32 AM11/14/14
to python_in...@googlegroups.com

The MAsset code I wrote

Hi David, was this code you shared somewhere? Or to which code are you referring?



For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

David Moulder

unread,
Nov 14, 2014, 1:11:14 PM11/14/14
to python_inside_maya
It was a custom asset / reference system that I wrote a good few years back at Eurocom.  At the time I wanted to use Maya asset system.  I nearly used it, but found some killer bugs when duplicating assets.  They basically kept loosing material assignments.  Also as assets use the reference system I had issue's with CGFX shaders being loaded and complied time and time again.  Slowing scene load times considerably.   So I rolled my own system by using our metaData node / class.  Inherited from the base class, hooked up to a db to track assets and versions (shotgun like) and rolled some utility methods for importing, updating, pushing edits back to source etc.  It was something was bespoke for the way artists wanted to work at the time.



For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages