Thursday, 16 August 2012

More Meta Fun!



Thought I'd share the current state of the MetaClass and MetaRig setups that I've been working on. The image above shows an initial test structure where the highlighted nodes are MetaClass network nodes. We have an initial MRIG node which is the entry point for all of this. Hanging directly off that are the main Rig controllers. We then have a SubMetaNode call ed Support with a Maya node hanging off it. Off the Support we also have a further MetaClass node called Facial which has lipsCtlr hanging off it. Now this is just a demo to show how we get round in this structure. The code for generating this is bellow
import Red9_Meta as r9Meta
import maya.cmds as cmds

mRig=r9Meta.MetaRig(name='MRIG')
mRig.select()

mRig.addRigCtrl('Chest_Ctr','Chest',boundData={'Side':'Centre'})
mRig.addRigCtrl('UpChest_Ctr','UpperChest',boundData={'Side':'Centre'})
mRig.addRigCtrl('Head_Ctr','Head',boundData={'Side':'Centre'})
mRig.addRigCtrl('Root_Ctr','Root',boundData={'Side':'Centre'})
mRig.addRigCtrl('L_Foot_Ctr','L_Foot',boundData={'Side':'Left'})
mRig.addRigCtrl('Hip_Ctr','Hips',boundData={'Side':'Centre'})

support=mRig.addSubMetaNode(nodeName='SupportNode',attr='Support')
support.connectChild(node='Settings_Node',attr='ExportData')

facial=support.addSubMetaNode(nodeName='FacialNode',attr='Facial')
facial.connectChild(node='Lips_Ctr',attr='Lips')
Now the beauty of this is that because the MetaClass base wraps all the Maya attrs and autofills the python objects dicts, we can lituarally walk the dag graph with dot complete! So to get to the Lips we can simply do the following, all of which autocompletes in the Maya scriptEditor for you ;)
mRig.Support.Facial.Lips
Also because of the way the mRig manages the Controls all of the controllers added above show up in the autocomplete on the mRig node. So you can just go MRig.Head to get the headCtrl back. I'm trying not to restrict this stuff, I'd rather make this as open as I can.

Again, the thing to bear in mind is that the main python objects __getattr__, __setattribute__ have been modified so that getting and setting all data types from Maya nodes is automatic. This includes getting and setting Emums and Message links.

 I'll up the latest build of this module is now up on my Google Drive, see download link in the Tags

cheers

 Red

Tuesday, 14 August 2012

MetaRig Class, looking for testers and feedback!


Going to do more on the MetaRig for Rig handling and finally look to integrate it into the whole tool chain over the next few weeks, hopefully I'll have a build with this all functional ready for testing soon. The idea is that you wire your rig to a MetaRig node and then no longer have to worry about setting the filters up in all the Red9 Ui's, they'll all just automatically pick up any MetaRigs in the scene and act appropriately.

Why, well with this setup it won't matter what rig you have, or how it's setup, this is just hidden data that binds up to anything you throw at it. It also means that via the api I'm doing you can just grab any controller in code in a very object oriented manner from the Python calls. So if you have a MetaRig node simply doing a dot complete on it will show you, and return all the controllers wired to it. It also means that all your code from that point on becomes completely generic.

From the Class Examples:

#MetaRigging!
#-----------------------------------------------------------
#This class is a wrapper of the main class aimed at managing 
#complex rigs and finding controllers. Simple concept, you 
#make a blank mRig node and just hook the controllers up to it.
import Red9_Meta as r9Meta
mRig=r9Meta.MetaRig()
#add all given nodes to the 'RigCtrl' msglink
mRig.addGenericCtrls(cmds.ls(sl=True))  
mRig.getRigCtrls()  //returns : all RigCtrls from above
 
#note that the default mClass connect will allow you to still 
#add a list of nodes to a specific msg attr.
mRig.connectChildren(cmds.ls(sl=True),'mirrorLeft')
 
#From a MayaNode return all connected mNodes as mClass objects
mNode=r9Meta.GetConnectedMeta(cmds.ls(sl=True))[0]
 
#The above is the most basic use. Wiring all given nodes to a 
#single attr, the issue here is to find a specific controller 
#from the list? So we have a singular Add function which binds 
#the given node to a single message attr, suffixed with 'CTRL_' 
 
mRig.addRigCtrl('MyMaya_Ctrl_Hips', 'Hips'))
mRig.CTRL_Hips  //return : MyMaya_Ctrl_Hips
 
#Note that because of the autofill on the object, once you
#have a mClass Rig object you'll get a list of all the hooked 
#Controllers (added by this method) on completion in the 
#scriptEditor. Whats more mRig.getRigCtrls() will still give you 
#a full list of them back.

Also I'm going to bind up some extra data to each controller thats added for the mirror setups that I'm working on.

Looking for testers if you fancy getting involved let me know!

Red

Friday, 27 July 2012

OOps

So I released v1.24 and forgot to patch the scriptEditor inspect for Maya2010 and 2013. Just patched the version on the download link.

Monday, 23 July 2012

Maya Script Editor - Code Inspector

This is a neat little bit of integration to the script editor's popup menu that's going into the latest build of the Red9 Pack, v1.24.
I've added a new menu item to the ScriptEditor RMB popup, "Red9_InspectFunction", which uses either the whatIs command for MEL or Python's inspect module to then lookup the source function file for the highlighted text, if found it will open up the mel or python module in the default editor on your system. Really handy for debugging!
Since this video I've also managed to get it to run from the history scroll as well as the editor itself which makes it even easier.



Sunday, 1 July 2012

r9Meta been playing

Just a few simple ideas but it all seems to make sense. So rather than having to always have a specific node that we use for metadata, I've removed all of that so that any Maya node can be passed in and managed by the same baseclass. Also been playing with adding a flag that when the Maya node is passed and the Python object made, it automatically pushes all the attributes from that Maya node directly to the Python Object, why? Well it gives you full auto-completion for all attributes in the editors which lets face it, when you're dealing with a big shader or material is a godsend!


Red9 - MetaClass Initial Demo from Red on Vimeo.

Tuesday, 26 June 2012

r9MetaClass Vimeo demo

This is a brief demo of the initial Red9 MetaClass Python API aimed at managing and wrapping data to a Maya MetaNode system. All data is serialized to Maya network nodes so is stored with the scene. There's handling for JSON serializing of complex data and retrieving that data back in a very neat and simple Pythonic manner, getting the data back directly from the Maya node but in a completely seamless way.

This is just the initial fleshing out, the long term aim to to provide a generic method of managing complex Maya rig structures and marking data without you having to write your own API. So you'd make an mClass rig node and hook the rig up to that making retrieval of controllers etc a doddle!

http://red9-consultancy.blogspot.co.uk/search/label/Download

All comments very welcome



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