Sunday, 24 June 2012

r9MetaClass : fleshing out a new Meta data system API

I'm just starting to flesh out a new python based metaData system for Maya, aimed at serializing complex data and managing systems in a more pythonic manner. The idea is that on a MayaNetwork node we handle all attribute calls (__getattribute__, __setattr__ , addAttr etc) and if needed serialize complex data such as dict/lists etc via JSON to a string attr. When you do a simple attr call to the metaClass it checks the MayaNode and if it's a JSON managed string, will give you back the complex data as it was, handling all the deserialization for you.

So from the class object you can do the following where 'complexAttr' is just a JSON serialized string attribute on the MayaNode itself

node.complexAttr['Meta']   
#deserialize attribute and from the returned dict give me the key value ['Meta']

It also manages connections via message links, all wrapped in the same pythonic manner. The same standard node.attr call to a message attr will give you back a list of connections to that msg attr itself.

There are a few other neat tricks in there too that I'm testing, although not yet sure of the best way to manage some of these, such as the r9Meta.GetMetaNodes() which will give you back not just the MayaMetaNodes, but those nodes initialized to the correct class object ready for use.

Anyway, I'm looking for testers and some ideas as to how to expand on this. Initially I was going to use it as part of a generic Rig marking system but kind of thinking it could go way further than that.

Mail me if you fancy a play with the API. It's also included in v1.24 of the studioPack, just cjeck the Download folder

Red

1 comment:

  1. Really neat, it sounds like Shotgun with nodes. I.e key/value pair assignment. My understanding is you have a messageNode type which stores the JSON data. And you have a python lib that when it queries the node for the JSON deserialize's it and does what it needs to do. JSON becomes the informational wrapper the metaNodes hierachy/children etc..

    ReplyDelete

Note: only a member of this blog may post a comment.