Red9_Meta¶
Red9 Meta is a full metaData API that deals with Maya nodes in a more seemless manor. I’ve tried to do as much documentation as I can both in terms of commenting the code and doing examples and Vimeo demos.
This is a big concept and I’ll be expanding these docs accordingly when I get more time.
Vimeo Demos:¶
- Develop Conference 2014 - MetaData in a Production Pipeline Video1 <https://vimeo.com/100882408>
- Develop Conference 2014 - MetaData in a Production Pipeline Video2 <https://vimeo.com/100883383>
- Develop Conference 2014 - MetaData in a Production Pipeline Video3 <https://vimeo.com/102463373>
- MetaData part1 <https://vimeo.com/61841345>
- MetaData part2 <https://vimeo.com/62546103>
- MetaData Part3 <https://vimeo.com/64258996>
- MetaData part4 <https://vimeo.com/72006183>
- MetaData MetaHUD <https://vimeo.com/65006622>
There are also some basic examples in the Red9 Package itself found under the examples folder.
Basic MetaClass Use:¶
Now moved to the examples folder for more detailed explanations
- Red9/examples/MetaData_Getting_started.py
- Red9/examples/MetaRig_Morpheus.py
Also see the unittesting folder to see what the code can do and what each function is expected to return
- Red9/tests
Key Functions
registerMClassInheritanceMapping () |
|
registerMClassNodeMapping ([nodeTypes]) |
Hook to allow you to extend the type of nodes included in all the getMeta searches. |
isMetaNode (node[, mTypes, checkInstance, ...]) |
Simple bool, Maya Node is or isn’t an mNode |
isMetaNodeInherited (node[, mInstances]) |
unlike isMetaNode which checks the node against a particular MetaClass, |
getMetaNodes (*args, **kws) |
Get all mClass nodes in scene and return as mClass objects if possible :param mTypes: only return meta nodes of a given type :param mInstances: idea - this will check subclass inheritance, ie, MetaRig would return ALL nodes who’s class is inherited from MetaRig. |
getConnectedMetaNodes (*args, **kws) |
From a given set of Maya Nodes return all connected mNodes |
getConnectedMetaSystemRoot (node[, mTypes, ...]) |
From a given node see if it’s part of a MetaData system, if so walk up the parent tree till you get to top meta node and return the class. |
Main Classes
MetaClass ([node, name, nodeType, autofill]) |
Base Class for Meta support. |
MetaRig (*args, **kws) |
Sub-class of Meta used as the back-bone of our internal rigging systems. |
MetaRigSubSystem (*args, **kws) |
SubClass of the MRig, designed to organize Rig sub-systems (ie L_ArmSystem, L_LegSystem..) within a complex rig structure. |
MetaRigSupport (*args, **kws) |
SubClass of MetaClass, designed to organize support nodes, solvers and other internal nodes within a complex rig structure which you may need to ID at a later date. |
MetaFacialRig (*args, **kws) |
SubClass of the MetaRig, designed to be manage Facial systems in the MetaData |
MetaFacialRigSupport (*args, **kws) |
SubClass of the MetaClass, designed to organize support nodes, solvers and other internal nodes within a complex rig structure which you may need to ID at a later date. |
MetaHIKCharacterNode (*args, **kws) |
Casting HIK directly to a metaClass so it’s treated as meta by default. |
MetaHIKControlSetNode (*args, **kws) |
Casting HIK directly to a metaClass so it’s treated as meta by default. |
MetaHUDNode (*args, **kws) |
SubClass of the MetaClass, designed as a simple interface for HUD management in Maya. |
MetaTimeCodeHUD |
======= |
MetaTimeCodeHUD (*args, **kws) |
Generate’s a HUD node connected to the main timecode attrs, | >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
-
registerMClassInheritanceMapping
()¶
-
printSubClassRegistry
()¶
-
getMClassMetaRegistry
()¶ Generic getWrapper to return the Registry from the global
-
getMClassInstances
(mInstances)¶ return a list of Registered metaClasses that are subclassed from the given classes. This is so in code/UI’s you can group metaClasses by their inheritance . . . ie, give me all export metaClasses that are registered
Parameters: mInstanes – given metaClass to test inheritance - cls or [cls]
-
mTypesToRegistryKey
(mTypes)¶ make sure we’re dealing with a list of class keys to process against the registry. Allows us to pass in str ‘MetaRig’ or r9Meta.MetaRig to the args for type checking
-
getMClassDataFromNode
(node, checkInstance=True)¶ from the node get the class to instantiate, this gives us a level of flexibility over mClass attr rather than pure hard coding as it was previously
Parameters: - node – node to retrieve the mClass binding from
- checkInstance – bool, specify whether to test the given node as a per existing instance this check is purely for speed internally so we don’t check the same thing over and over again
-
registerMClassNodeMapping
(nodeTypes=[])¶ Hook to allow you to extend the type of nodes included in all the getMeta searches. Allows you to expand into using nodes of any type as metaNodes
Parameters: nodeTypes – allows you to expand metaData and use any nodeType default is always ‘network’ Note
this now validates ‘nodeTypes’ against Maya registered nodeTypes before being allowed into the registry. Why, well lets say you have a new nodeType from a plugin but that plugin isn’t currently loaded, this now stops that type being generically added by any custom boot sequence.
-
printMetaTypeRegistry
()¶
-
getMClassNodeTypes
()¶ Generic getWrapper for all nodeTypes registered in the Meta_NodeType global
-
resetMClassNodeTypes
()¶
-
generateUUID
()¶ unique UUID used by the caching system
-
registerMClassNodeCache
(mNode)¶ Add a given mNode to the global RED9_META_NODECACHE cache of currently instantiated MetaNode objects.
Parameters: mNode – instantiated mNode to add
-
getMetaFromCache
(mNode)¶ Pull the given mNode from the RED9_META_NODECACHE if it’s already be instantiated.
Parameters: mNode – str(name) of node from DAG
-
upgrade_toLatestBindings
(*args)¶ take a current scene and upgrade all the mNodes to include any new binding attrs that the base class may have been upgraded to use.
-
printMetaCacheRegistry
()¶ print the current VALID Cache of instantiated MetaNodes Note that we call a cleanCache before printing to remove any currently invalid MObjects from the Cache.
-
cleanCache
()¶ Run through the current cache of metaNodes and confirm that they’re all still valid by testing the MObjectHandles.
-
removeFromCache
(mNodes)¶
-
resetCache
(*args)¶
-
resetCacheOnSceneNew
(*args)¶
-
getMClassNodeCache
()¶ Generic getWrapper for all nodeTypes registered in the Meta_NodeType global
-
getMObject
(node)¶ base wrapper to get the MObject from node
-
nodeLockManager
(func)¶ Simple decorator to manage metaNodes which are locked. Why lock?? Currently just the metaRig and therefore any subclasses of that are locked. The reason is that the Maya ‘network’ node I use has issues when certain connections are deleted, the node itself can get deleted and cleanup, removing the entire network! Try it, make a metaNode and key an attr on it, then run cutKeys...the node will be deleted.
This decorator is used to manage the unlocking of self for all calls that require change access rights to the ‘network’ node itself.
-
pymelHandler
(func)¶
-
attributeDataType
(val)¶ Validate the attribute type for all the cmds handling
-
isMetaNode
(node, mTypes=[], checkInstance=True, returnMClass=False)¶ Simple bool, Maya Node is or isn’t an mNode
Parameters: - node – Maya node to test
- mTypes – only match given MetaClass’s - str or class accepted
- checkInstance – bool, used only internally for optimisation
- returnMClass – if True return the str(mClass) that this node is bound too
Note
this does not instantiate the mClass to query it like the isMetaNodeInherited which has to figure the subclass mapping
-
isMetaNodeInherited
(node, mInstances=[])¶ unlike isMetaNode which checks the node against a particular MetaClass, this expands the check to see if the node is inherited from or a subclass of a given Meta base class, ie, part of a system TODO : we COULD return the instantiated metaClass object here rather than just a bool??
-
isMetaNodeClassGrp
(node, mClassGrps=[])¶ check the mClassGrp attr to see if it matches the given
-
getMetaNodes
(*args, **kws)¶ Get all mClass nodes in scene and return as mClass objects if possible :param mTypes: only return meta nodes of a given type :param mInstances: idea - this will check subclass inheritance, ie, MetaRig would
return ALL nodes who’s class is inherited from MetaRig. Allows you to group the data more efficiently by base classes and their inheritanceParameters: - mClassGrps – checks the mClassGrp used to soft grp nodes and mark ones as a certain system type without looking at class inheritance. Good for marking key classes as bases
- mAttrs – uses the FilterNode.lsSearchAttributes call to match nodes via given attrs
- dataType – default=’mClass’ return the nodes already instantiated to the correct class object. If not then return the Maya node itself
- nTypes – only inspect nodes of a given Type
-
getMetaRigs
(mInstances='MetaRig', mClassGrps=['MetaRig'])¶ Wrapper over the get call to fire back specifically MetaRigs. We use mInstances rather than mTypes directly for MetaRig to cope with people subclassing, then we clamp the search to the Root MetaRig using the mClassGrps variable. This probably will expand as it’s tested
-
getUnregisteredMetaNodes
()¶ Inspect all nodes for the mClass attrs, then see if those nodes and mClass types are currently registered in the systems. This means you can inspect files from others who have bespoke MClass’s and still see their node structures even though you won’t be able to use or return their class objects
-
getConnectedMetaNodes
(*args, **kws)¶ From a given set of Maya Nodes return all connected mNodes Default return is mClass objects
Parameters: - nodes – nodes to inspect for connected meta data, note these are cmds MAYA nodes
- source – bool clamp the search to the source side of the graph
- destination – bool clamp the search to the destination side of the graph
- mTypes – return only given MetaClass’s
- mInstances – this will check subclass inheritance, ie, ‘MetaRig’ would return ALL nodes who’s class is inherited from MetaRig. Allows you to group the data more efficiently by base classes and their inheritance
- mAttrs – uses the FilterNode.lsSearchAttributes call to match nodes via given attrs
- dataType – default=’mClass’ return the nodes already instantiated to the correct class object. If not then return the Maya node
- nTypes – only return nodes of a given type, note this type must be registered to meta!
-
getConnectedMetaSystemRoot
(node, mTypes=[], ignoreTypes=[], mSystemRoot=True, **kws)¶ From a given node see if it’s part of a MetaData system, if so walk up the parent tree till you get to top meta node and return the class.
Parameters: - ignoreTypes – if the given mClass node types are found to be systemRoots ignore them why, lets say we have a system with several mNodes that are technically the head of the system and you need to skip a given type.
- mTypes – like the rest of Meta, if you give it a specific mType to find as root it will do just that if that node is a root node in the system.
- mSystemRoot – whether to respect the mSystemRoot abort bool on the nodes, default=True
Note
this walks upstream only from the given node, so if you effectively have multiple root nodes in the system but wired to different parts of the network, and when walking upstream from the given you only get to one of ththose because of the network wiring, then that is correct.
-
convertMClassType
(*args, **kws)¶ change the current mClass type of the given class instance. This used to be an internal func in eth baseClass but that seemed to make no sense as you’re mutating the class dynamically
Parameters: - cls – initialize mClass object t9o mutate
- newMClass – new class definition for the given cls
Note
If you’re converting a StandardWrapped Maya node to a fully fledged mNode then you also need to ensure that that NODETYPE is registered to meta or else it won’t get picked up when you run any of the gets.
-
convertNodeToMetaData
(nodes, mClass)¶ pass in a node and convert it to a MetaNode, assuming that the nodeType is valid in the metaNodeTypesRegistry.
Parameters: - nodes – nodes to cast to mClass instances
- mClass – mClass class to convert them too
Note
ideally you should use the convertMClassType func now as that wraps this if the nodes passed in aren’t already instanitated or bound to meta
-
delete_mNode
(mNode)¶ wrapper to delete a given mNode via the standard mClass call rather than the mNodes internal class.delete() call to avoid subclass issues when calling super().delete()
-
class
MClassNodeUI
(mTypes=None, mInstances=None, mClassGrp=None, closeOnSelect=False, funcOnSelection=None, sortBy='byClass', allowMulti=True)¶ Bases:
object
Simple UI to display all MetaNodes in the scene
Parameters: - mTypes – MetaNode class to search and display ‘MetaRig’
- mInstances – MetaNode inheritance map, ie show all subclass of mType..
- closeOnSelect – on text select close the UI
- funcOnSelection – function to run where the selected mNode is expected as first arg, ie funcOnSelection=cmd.select so that when run the item is selected in the UI cmds.select(item) is run. Basically used as a dynamic callback
- sortBy – Sort the nodes found ‘byClass’ or ‘byName’
- allowMulti – allow multiple selection in the UI
-
classmethod
show
()¶
-
fitTextScrollFucker
()¶ bodge to resize tghe textScroll as the default Maya control is SHITE!
-
graphNetwork
(*args)¶
-
selectCmd
(*args)¶ callback run on select in the UI, allows you to run the func passed in by the funcOnSelection arg
-
deleteCall
(*args)¶
-
doubleClick
(*args)¶ run the generic meta.getChildren call and select the results
-
fillScroll
(sortBy=None, *args)¶
-
printRegisteredNodeTypes
(*args)¶
-
printRegisteredMetaClasses
(*args)¶
-
printMetaNodeCache
(*args)¶
-
class
MetaClass
(node=None, name=None, nodeType='network', autofill='all', *args, **kws)¶ Bases:
object
Base Class for Meta support. This manages all the attribute and class management for all subsequent inherited classes. This is the core of the MetaData factory API
Parameters: - node – Maya Node - if given we test it for the mClass attribute, if it exists we initialize a class of that type and return. If not passed in then we make a new network node for the type given.
- name – only used on create, name to set for the new Maya Node (self.mNode)
- nodeType – allows you to specify a node of type to create as a new mClass node. default is ‘network’, not that for any node to show up in the get calls that type MUST be registered in the RED9_META_NODETYPE_REGISTERY
- autofill – ‘str’ cast all the MayaNode attrs into the class dict by default. Updated: modes: ‘all’ or ‘messageOnly’. all casts every attr, messageOnly fills the node with just message linked attrs (designed for MetaClass work with HIK characterNode)
Note
mNode is now a wrap on the MObject so will always be in sync even if the node is renamed/parented
-
cached
= None¶
-
UNMANAGED
= ['mNode', 'mNodeID', '_MObject', '_MObjectHandle', '_MFnDependencyNode', '_lockState', 'lockState', '_forceAsMeta', '_lastDagPath', '_lastUUID']¶
-
isValid
()¶ a metaNode in this case is valid if it has connections, if not it’s classed invalid
-
isValidMObject
()¶ validate the MObject, without this Maya will crash if the pointer is no longer valid TODO: thinking of storing the dagPath when we fill in the mNode to start with and if this test fails, ie the scene has been reloaded, then use the dagPath to refind and refil the mNode property back in.... maybe??
-
isSystemRoot
()¶ used by the getConnectedMetaSystemRoot call to identify if this node is a top system node. Having his as an attr allows us to designate certain subsystems as root nodes in their own right. Ie, Facial controlBoard
-
mNode
¶ mNode is the pointer to the Maya object itself, retrieved via the MObject under the hood so it’s always in sync.
-
mNodeID
¶
-
mNodeMObject
¶ exposed wrapper to return the MObject directly, this passes via the MObjectHandle to ensure that the MObject cached is still valid
-
getInheritanceMap
()¶ return the inheritance mapping of this class instance
-
lockState
¶ Lockstate is just that, the lockNode state of the Maya node
-
setUUID
()¶ unique UUID used by the caching system
-
getUUID
()¶
-
attrType
(attr)¶ return the api attr type
-
hasAttr
(attr)¶ simple wrapper check for attrs on the mNode itself. Note this is not run in some of the core internal calls in this baseClass
-
attrIsLocked
(attr)¶ check the attribute on the mNode to see if it’s locked
-
attrSetLocked
(*args, **kws)¶ set the lockState of a given attr on the mNode
-
renameAttr
(*args, **kws)¶ wrap over cmds.renameAttr
-
delAttr
(*args, **kws)¶ delete a given attr
-
addAttr
(*args, **kws)¶ Wrapped version of Maya addAttr that manages the basic type flags for you whilst also setting the attr on the MayaNode/class object itself. I now merge in **kws to the dict I pass to the add and set commands here so you can specify all standard cmds.addAttr, setAttr flags in the same call. ie min, max, l, k, cb
Parameters: - attr – attribute name to add (standard ‘longName’ flag)
- value – initial value to set, if a value is given the attribute type is automatically determined for you.
- attrType – specify the exact type of attr to add. By default I try and resolve this for you from the type of value passed in.
- hidden – whether the attr is set available in the channelBox (only applies keyable attrs)
Note
specific attr management for given types below:
>>> double3: self.addAttr(attr='attrName', attrType='double3',value=(value1,value2,value3)) >>> float3: self.addAttr(attr='attrName', attrType='float3', value=(value1,value2,value3)) >>> enum: self.addAttr(attr='attrName', attrType='enum', value=1, enumName='Centre:Left:Right') >>> doubleArray: self.addAttr(attr='attrName', attrType='doubleArray', value=[1.0,2.0,3.0,4.0,5.0]) >>> complex: self.addAttr('jsonDict', {'a':1.0,'b':2.0,'c':3.3,'d':['a','b','c']})
Note
max values for int is 2,147,483,647 (int32)
-
listAttrsOfType
(Type='message')¶ this is a fast method to list all attrs of type on the mNode
>>> [attr for attr in cmds.listAttr(self.mNode) if cmds.getAttr('%s.%s' % (self.mNode,attr),type=True)=='message']
Simply using the above cmds calls is DOG SLOW upto this which goes via the Api. TODO: expand the Type support here
-
shortName
()¶
-
select
(*args, **kws)¶ args and kws are now passed through into the Maya select call
-
rename
(*args, **kws)¶ rename the mNode itself, again because we get the mNode via the MObject renaming is handled correctly
Parameters: - name – new name for the mNode
- renameChildLinks – set to False by default, this will rename connections back to the mNode from children who are connected directly to it, via an attr that matches the current mNode name. These connected Attrs will be renamed to reflect the change in node name
-
delete
()¶ delete the mNode and this class instance
Note that if you delete a ‘network’ node then by default Maya will delete connected child nodes unless they’re wired. To prevent this set the self.lockState=True in your classes __init__
-
gatherInfo
(level=0, *args, **kws)¶ a generic gather function designed to be overloaded at the class level and used to collect specific information on the given class in a generic way. This is used by the r9Aninm format in Pro to collect key info on the system being saved against
Parameters: level – added here for the more robust checking that the rigging systems need
-
isReferenced
()¶ is node.mNode referenced?
-
referenceNode
()¶ if referenced return the referenceNode itself
-
referencePath
(wcn=False)¶ if referenced return the referenced filepath
-
nameSpace
()¶ This flag has been modified to return just the direct namespace of the node, not all nested namespaces if found. Now returns a string
-
nameSpaceFull
(asList=False)¶ the namespace call has been modified to only return the single direct namespace of a node, not the nested. This new func will return the namespace in it’s entirity either as a list or a catenated string
Parameters: asList – either return the namespaces in a list or as a catenated string (default)
-
isChildNode
(node, attr=None, srcAttr=None)¶ test if a node is already connected to the mNode via a given attr link. Why the wrap? well this gets over the issue of array index’s in the connections
cmds.isConnected(‘node.attr[0]’,’other.attr[0]’) fails if simply asked: cmds.isConnected(‘node.attr’,other.attr’)
-
connectChildren
(*args, **kws)¶ Fast method of connecting multiple nodes to the mNode via a message attr link. This call generates a MULTI message on both sides of the connection and is designed for more complex parent child relationships
Parameters: - nodes – Maya nodes to connect to this mNode
- attr – Name for the message attribute
- srcAttr – if given this becomes the attr on the child node which connects it to self.mNode. If NOT given this attr is set to self.mNodeID
- cleanCurrent – Disconnect and clean any currently connected nodes to this attr. Note this is operating on the mNode side of the connection, removing any currently connected nodes to this attr prior to making the new ones
- force – Maya’s default connectAttr ‘force’ flag, if the srcAttr is already connected to another node force the connection to the new attr
- allowIncest – Over-ride the default behaviour when dealing with child nodes that are standard Maya Nodes not metaNodes. Default in this case is to NOT index manage the plugs, this flag overloads that, allow multiple parents.
- srcSimple – By default when we wire children we expect arrays so both plugs on the src and dest side of the connection are index managed. This flag stops the index and uses a single simple wire on the srcAttr side of the plug ( the child )
TODO: check the attr type, if attr exists and is a non-multi message then don’t run the indexBlock
-
connectChild
(*args, **kws)¶ Fast method of connecting a node to the mNode via a message attr link. This call generates a NONE-MULTI message on both sides of the connection and is designed for simple parent child relationships.
Note
this call by default manages the attr to only ONE CHILD to avoid this use cleanCurrent=False
Parameters: - node – Maya node to connect to this mNode
- attr – Name for the message attribute
- srcAttr – If given this becomes the attr on the child node which connects it to self.mNode. If NOT given this attr is set to self.mNodeID
- cleanCurrent – Disconnect and clean any currently connected nodes to the attr on self. Note this is operating on the mNode side of the connection, removing any currently connected nodes to this attr prior to making the new ones
- force – Maya’s default connectAttr ‘force’ flag, if the srcAttr is already connected to another node force the connection to the new attr
- allow_multi – allows the same node to connect back to this mNode under multiple wires default behaviour is to only let a single wire from an mNode to a child
TODO: do we move the cleanCurrent to the end so that if the connect fails you’re not left with a half run setup?
-
connectParent
(*args, **kws)¶ Fast method of connecting message links to the mNode as parents :param nodes: Maya nodes to connect to this mNode :param attr: Name for the message attribute on the PARENT! :param srcAttr: If given this becomes the attr on the node which connects it
to the parent. If NOT given this attr is set to parents shortNameParameters: cleanCurrent – Exposed from teh connectChild code which is basically what this is running in reverse TODO: Modify so if a metaClass is passed in use it’s addAttr cmd so the new attr is registered in the class given
TODO: Manage connection Index like the connectChildren call does?
-
disconnectChild
(*args, **kws)¶ disconnect a given child node from the mNode. Default is to remove the connection attribute in the process, cleaning up both sides of the connection. Note that the attrs only get removed if nothing else is connected to it, ie, it’s safe to do so. :param node: the Maya node to disconnect from the mNode :param deleteSourcePlug: if True delete SOURCE side attribiute after disconnection
but ONLY if it’s no longer connected to anything else.Parameters: deleteDestPlug – if True delete the DESTINATION side attribiute after disconnection but ONLY if it’s no longer connected to anything else. >>> #testCode: >>> master = r9Meta.MetaClass(name = 'master') >>> master2 = r9Meta.MetaClass(name = 'master2') >>> child1 = r9Meta.MetaClass(name = 'child1') >>> child2 = r9Meta.MetaClass(name = 'child2') >>> cube=cmds.ls(cmds.polyCube()[0],l=True)[0] >>> master.connectChildren([child1,child2,cube],'modules','puppet') >>> master2.connectChildren([child1.mNode,child2.mNode,cube],'time','master',force=True) >>> master.connectChildren([child1,child2],'time','master',cleanCurrent=True) >>> >>> master.disconnectChild(child2,'time') >>> #or >>> master.disconnectChild(child2)
-
addChildMetaNode
(mClass, attr, srcAttr=None, nodeName=None, **kws)¶ Generic call to add a MetaNode as a Child of self
Parameters: - mClass – mClass to generate, given as a valid key to the RED9_META_REGISTERY ie ‘MetaRig’ OR a class object, ie r9Meta.MetaRig
- attr – message attribute to wire the new node too
- name – optional name to give the new name
-
getChildMetaNodes
(*args, **kws)¶ Find any connected Child MetaNodes to this mNode.
Parameters: - walk – walk the connected network and return ALL children conntected in the tree
- mAttrs – only return connected nodes that pass the given attribute filter
- stepover – if you’re passing in ‘mTypes’ or ‘mInstances’ flags then this dictates if we continue to walk down a tree if it’s parent didn’t match the given type, default is False which will abort a tree who’s parent didn’t match. With stepover=True we simply stepover that node and continue down all child nodes
Note
mAttrs is only searching attrs on the mNodes themselves, not all children and although there is no mTypes flag, you can use mAttrs to get childnodes of type by going getChildMetaNodes(mAttrs=’mClass=MetaRig’)
-
getParentMetaNode
(**kws)¶ Find any connected Parent MetaNode to this mNode
Note
Because the **kws are passed directly to the getConnectedMetaNods func, it will also take ALL of that functions kws source=True, destination=True, mTypes=[], mInstances=[], mAttrs=None, dataType=’mClass’
TODO: implement a walk here to go upstream
-
getChildren
(*args, **kws)¶ This finds all UserDefined attrs of type message and returns all connected nodes This is now being run in the MetaUI on doubleClick. This is a generic call, implemented and over-loaded on a case by case basis. At the moment the MetaRig class simple calls mRig.getRigCtrls() in the call, but it means that we don’t call .mRig.getRigCtrls() in generic meta functions.
Parameters: - walk – walk all subMeta connections and include all their children too
- mAttrs – only search connected mNodes that pass the given attribute filter (attr is at the metaSystems level)
- cAttrs – only pass connected children whos connection to the mNode matches the given attr (accepts wildcards)
- nAttrs – search returned MayaNodes for given set of attrs and only return matched nodes
- asMeta – return instantiated mNodes regardless of type
- asMap – return the data as a map such that {mNode.plugAttr:[nodes], mNode.plugAttr:[nodes]}
Note
mAttrs is only searching attrs on the mNodes themselves, not the children cAttrs is searching the connection attr names from the mNodes, uses the cmds.listAttr ‘st’ flag
-
static
getNodeConnectionMetaDataMap
(node, mTypes=[])¶ This is a generic wrapper to extract metaData connection info for any given node used currently to build the pose dict up, and compare / match the data on load. In the base implementation this gives you a dict of mNodeID and attr which the nodes is connected too.
Parameters: node – node to inspect and get the connection data back from Returns: mNodes={} which is directly pushed into the PoseFile under the [metaData] key Note
This is designed to be overloaded so you can craft your own metaData block in the poseFiles, allows you to craft the data you want to store against a node.
-
getNodeConnetionAttr
(node)¶ really light wrapper, designed to return the attr via which a node is connected to this metaNode
Parameters: node – node to test connection attr for Note
This will be depricated soon and replaced by getNodeConnections which is more flexible as it returns and filters all plugs between self and the given node.
-
getNodeConnections
(node, filters=[])¶ really light wrapper, designed to return all connections between a given node and the mNode
Parameters: - node – node to test connection attr for
- filters – filter string to match for the returns
-
deleteEntireMetaRigStructure
(searchNode=None)¶ This is a hard core unplug and cleanup of all attrs added by the MetaRig, all connections and all nodes. Use CAREFULLY!
-
class
MetaRig
(*args, **kws)¶ Bases:
Red9.core.Red9_Meta.MetaClass
Sub-class of Meta used as the back-bone of our internal rigging systems. This is the core of how we hook all our tools to meta in a seamless manner and bind some core functionality.
Parameters: name – name of the node and in this case, the RigSystem itself -
gatherInfo
(level=0, *args, **kws)¶ gather key info on this system
-
settings
¶ bound filterSettings object used by the Animation Systems from now on so that this data can be bound directly to the rig so we don’t have to use the preset config’s all the time
-
isValid
()¶ simple check to see if this definition is still valid and wired to controllers and not just to empty subSystems as is the case if you were to delete all the dag nodes in a rig, leaving the MetaRig structure in-tact but useless
-
delete
(full=True)¶ full delete and clean of a rig system and network
-
ctrl_main
¶ why wrap, because when we subclass, IF we’ve modified the CRTL_Prefix then we can’t rely on the default CTRL_Main[0] wire, so we wrap it with the current instances self.CTRL_Prefix
-
characterSet
¶ return the first connected characterSet found to children
-
addGenericCtrls
(nodes)¶ Pass in a list of objects to become generic, non specific controllers for a given setup. These are all connected to the same slot so don’t have the search capability that the funct below gives
-
addRigCtrl
(node, ctrType, mirrorData=None, boundData=None)¶ Add a single CTRL of managed type as a child of this mRig.
Parameters: - node – Maya node to add
- ctrType – Attr name to assign this too
- mirrorData – {side:’Left’, slot:int, axis:’translateX,rotateY,rotateZ’..}
- boundData – {} any additional attrData, set on the given node as attrs
Note
mirrorData[slot] must NOT == 0 as it’ll be handled as not set by the core.ctrType >> ‘Main’ is the equivalent of the RootNode in the FilterNode calls.TODO: allow the mirror block to include an offset so that if you need to inverse AND offset by 180 to get left and right working you can still do so.
-
getRigCtrls
(walk=False, mAttrs=None)¶ Depricated Code - use getChildren call now
-
getChildren
(walk=True, mAttrs=None, cAttrs=[], nAttrs=[], asMeta=False, asMap=False, incFacial=False)¶ Massively important bit of code, this is used by most bits of code to find the child controllers linked to this metaRig instance.
<<<<<<< HEADParameters: - walk – walk all subMeta connections and include all their children too
- mAttrs – only search connected mNodes that pass the given attribute filter (attr is at the metaSystems level)
- cAttrs – only pass connected children whos connection to the mNode matches the given attr (accepts wildcards)
- nAttrs – search returned MayaNodes for given set of attrs and only return matched nodes
- asMeta – return instantiated mNodes regardless of type
- asMap – return the data as a map such that {mNode.plugAttr:[nodes], mNode.plugAttr:[nodes]}
- incFacial – if we have a facial system linked include it’s children in the return (uses the getFacialSystem to id the facial node)
Note
MetaRig getChildren has overloads adding the CTRL_Prefix to the cAttrs so that the return is just the controllers in the rig. It also now has additional logic to add any FacialCore system children by adding it’s internal CTRL_Prefix to the list
-
selectChildren
(walk=True, mAttrs=None, cAttrs=[], nAttrs=[])¶ light wrap over the getChildren so we can more carefully manage it in some of the pro proc bindings
Parameters: - walk – walk all subMeta connections and include all their children too
- mAttrs – only search connected mNodes that pass the given attribute filter (attr is at the metaSystems level)
- cAttrs – only pass connected children whos connection to the mNode matches the given attr (accepts wildcards)
- nAttrs – search returned MayaNodes for given set of attrs and only return matched nodes
Note
the wrapper also accepts the ‘Shift’ modifier key, if pressed when this is called then we set the selection to ‘add’ else it’s a fresh selection thats made
=======Note
MetaRig getChildren has overloads adding the CTRL_Prefix to the cAttrs so that the retunr is just the controllers in the rig. It also now has additional logic to add any FacialCore system chidren by adding it’s internal CTRL_Prefix to the list
>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e-
getSkeletonRoots
()¶ get the Skeleton Root, used in the poseSaver. By default this looks for a message link via the attr “exportSkeletonRoot” to the skeletons root jnt always returns a list!
-
getFacialSystem
()¶ if we have a FacialCore node return it. This allows you to modify how you wire up your facial system to metaData but gives us a consistent hook
-
addWristCtrl
(node, side, axis=None)¶
-
addElbowCtrl
(node, side, axis=None)¶
-
addClavCtrl
(node, side, axis=None)¶
-
addFootCtrl
(node, side, axis=None)¶
-
addKneeCtrl
(node, side, axis=None)¶
-
addPropCtrl
(node, side, axis=None)¶
-
addMainCtrl
(node, side='Centre', axis=None)¶
-
addRootCtrl
(node, side='Centre', axis=None)¶
-
addHipCtrl
(node, side='Centre', axis=None)¶
-
addChestCtrl
(node, side='Centre', axis=None)¶
-
addHeadCtrl
(node, side='Centre', axis=None)¶
-
addNeckCtrl
(node, side='Centre', axis=None)¶
-
addSupportMetaNode
(attr, nodeName=None, mClass='MetaRigSupport', **kws)¶ Not sure the best way to do this, but was thinking that the main mRig node should be able to have sub MetaClass nodes to cleanly define what nodes are AnimCtrls, and what nodes you want to tag as Support subsystems, ie, ikSolvers and construction nodes within the rig
Parameters: - attr – Attribute used in the message link. Note this is what you use to transerve the Dag tree so use something sensible!
- nodeName – Name of the MetaClass network node created
- mClass – the class to be used for the support node - ‘MetaRigSupport’ by default
-
addSupportNode
(node, attr, boundData=None)¶ Add a single MAYA node flagged as a SUPPORT node of managed type Really in the MetaRig design these should be wired to a MetaRigSupport node
Parameters: - node – Maya node to add
- attr – Attr name to assign this too
- boundData – {} Data to set on the given node as attrs
-
addMetaSubSystem
(systemType, side, attr=None, nodeName=None, mClass='MetaRigSubSystem', buildflags={})¶ Basic design of a MetaRig is that you have sub-systems hanging off an mRig node, managing all controllers and data for a particular system, such as an Arm system.
Parameters: - systemType – Attribute used in the message link. Note this is what you use <<<<<<< HEAD to traserve the Dag tree so use something sensible!
- side – Side to designate the system. This is an enum: Centre,Left,Right
- attr – wire name to use in the connections, if not given wire will be side[0]_systemType_’System’ ======= to transerve the Dag tree so use something sensible!
- mirrorSide – Side to designate the system. This is an enum: Centre,Left,Right >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
- nodeName – Name of the MetaClass network node created
- mClass – the class to be used for the support node - ‘MetaRigSubSystem’ by default
-
set_ctrlColour
(colourIndex=4)¶ set the override colour of a given nodes shapes
-
getMirrorData
()¶ Bind the MirrorObject to this instance of MetaRig.
Note
you must run this binding function before using any of the inbuilt mirror functions
-
loadMirrorDataMap
(mirrorMap)¶ load a mirror setup onto this rig from a stored mirrorMap file
Parameters: mirrorMap – mirror file to load
-
saveMirrorDataMap
(filepath)¶ save the current mirror setup for this rig to file
Parameters: filepath – filepath to store the mirrorMap too
-
getMirror_opposites
(nodes, forceRefresh=False)¶ from the given nodes return a map of the opposite pairs of controllers so if you pass in a right controller of mirrorIndex 4 you get back the left[4] mirror node and visa versa. Centre controllers pass straight through
Parameters: - nodes – nodes to get the opposites from
- forceRefresh – forces the mirrorDic (which is cached) to be updated
-
getMirror_ctrlSets
(set='Centre', forceRefresh=False)¶ from the metaNode grab all controllers and return sets of nodes based on their mirror side data
Parameters: - set – which set/side to get, valid = ‘Left’ ,’Right’, ‘Center’
- forceRefresh – forces the mirrorDic (which is cached) to be updated
-
getMirror_lastIndexes
(side, forceRefresh=False)¶ get the last mirror index for a given side
Parameters: - side – side to check, valid = ‘Left’ ,’Right’, ‘Center’
- forceRefresh – forces the mirrorDic (which is cached) to be updated
-
getMirror_nextSlot
(side, forceRefresh=False)¶ return the next available slot in the mirrorIndex list for a given side
Parameters: - side – side to check, valid = ‘Left’ ,’Right’, ‘Center’
- forceRefresh – forces the mirrorDic (which is cached) to be updated
-
mirror
(nodes=None, mode='Anim')¶ direct mapper call to the Mirror functions
Parameters: - nodes – nodes to mirror, if None then we process the entire rig
- mode – either ‘Anim’ or ‘Pose’
-
poseCacheStore
(*args, **kws)¶ intended as a cached pose for this mRig, if an attr is given then the cached pose is stored internally on the node so it can be loaded back from the mNode internally. If not given then the pose is cached on this object instance only.
Parameters: - attr – optional - attr to store the cached pose to
- filepath – optional - path to store the pose too
- incRoots – passed directly to the filterSettings object in the pose, do we process self.ctrl_main?
-
poseCacheLoad
(nodes=None, attr=None, filepath=None, incRoots=True, relativePose=False, relativeRots='projected', relativeTrans='projected', maintainSpaces=False, *args, **kws)¶ load a cached pose back to this mRig. If attr is given then its assumed that that attr is a cached poseDict on the mNode. If not given then it will load the cached pose from this objects instance, if there is one stored.
Parameters: - nodes – if given load only the cached pose to the given nodes
- attr – optional - attr in which a pose has been stored internally on the mRig
- filepath – optional - posefile to load back
- incRoots – passed directly to the filterSettings object in the pose, do we process self.ctrl_main?
TODO: add relative flags so that they can pass through this call
-
poseCompare
(poseFile, supressWarning=False, compareDict='skeletonDict', filterMap=[], ignoreBlocks=[], ignoreStrings=[], ignoreAttrs=[])¶ Integrated poseCompare, this checks the mRigs current pose against a given poseFile. This checks against the ‘skeletonDict’
Parameters: - poseFile – given .pose file with valid skeletonDict block
- supressWarning – if False raise the confirmDialogue
- compareDict – what block in the poseFile to compare the data against
- filterMap – if given this is used as a high level filter, only matching nodes get compared others get skipped. Good for passing in a master core skeleton to test whilst ignoring extra nodes
- ignoreBlocks – used to stop certain blocks in the compare from causing a fail eg : [‘missingKeys’]
- ignoreAttrs – allows you to skip given attrs from the poseCompare calls
Returns: returns a ‘PoseCompare’ class object with all the compare data in it
-
nodeVisibility
(state, skip=[])¶ simple wrapper to hide all ctrls in the rig via their shapeNodes.lodVisibility so it doesn’t interfer with any display layers etc
Parameters: - state – bool to pass to the lodVisibility attr
- skip – [] child attrs on the mNode to skip during the process allowing certain controllers not to be effected
-
hideNodes
()¶ wrap over the nodeVisibility to set False for all Controllers with the exceptiojn of the Main_Ctrl
-
unHideNodes
()¶ wrap over the nodeVisibility to set True for all Controllers with the exceptiojn of the Main_Ctrl
-
saveAttrMap
(*args, **kws)¶ store AttrMap to the metaRig, saving the chBox state of ALL attrs for ALL nodes in the hierarchy
-
loadAttrMap
(*args)¶ load AttrMap from the metaRig, returning the chBox state of ALL attrs for ALL nodes in the hierarchy
-
saveZeroPose
(*args, **kws)¶ serialize the r9Pose file to the node itself
-
loadZeroPose
(nodes=None, *args)¶ load the zeroPose form the internal dict
Parameters: nodes – optional, load at subSystem level for given nodes
-
getAnimationRange
(nodes=None, setTimeline=False)¶ return the extend of the animation range for this rig and / or the given controllers
Parameters: - nodes – if given only return the extent of the animation data from the given nodes
- setTimeLine – if True set the playback timeranges also, default=False
-
<<<<<<< HEAD
-
keyChildren
(nodes=[], walk=True, mAttrs=None, cAttrs=[], nAttrs=[])¶ return True if any of the rig’s controllers have existing animation curve/key data
Parameters: - nodes – nodes to check, if None process the entire rig via all the flags which are passed into the getChildren call
- walk – walk all subMeta connections and include all their children too
- mAttrs – only search connected mNodes that pass the given attribute filter (attr is at the metaSystems level)
- cAttrs – only pass connected children whos connection to the mNode matches the given attr (accepts wildcards)
- nAttrs – search returned MayaNodes for given set of attrs and only return matched nodes
-
hasKeys
(nodes=[], walk=True)¶
=======
-
hasKeys
(nodes=[])¶
>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
return True if any of the rig’s controllers have existing animation curve/key data
Parameters: nodes – nodes to check, if None process the entire rig
-
<<<<<<< HEAD
cutKeys
(nodes=[], reset=True, walk=True)¶
=======
cut all animation keys from the rig and reset
Parameters: - nodes – if passed in only cutKeys on given nodes
- reset – if true reset the rig after key removal
cutKeys
(nodes=[], reset=True)¶ >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e-
saveAnimation
(filepath, incRoots=True, useFilter=True, timerange=(), storeThumbnail=False, force=False, userInfoData='', **kws)¶ - : PRO_PACK :
- Binding of the animMap format for storing animation data out to file
Parameters: - filepath – r9Anim file to load
- incRoots – do we include the root node in the load, in metaRig case this is ctrl_main
- useFilter – do we process all children of this rig or just selected
- timerange – specific a timerange to store, else store all
- storeThumbnail – this will be an avi but currently it’s a pose thumbnail
- force – allow force write on a read only file
- userInfoData – user information used by the AnimStore UI only
-
loadAnimation_postload_call
(feedback, *args, **kws)¶ - : PRO_PACK :
- Added to be Overloaded at the class level!
call passed into the animMap class and run AFTER the r9Anim file is loaded on the MetaRig, this allows you to add functionality to the base load to extract extra data from the animMap and act upon it
This allows us to act on the animMap stored on the class object and rebuld data from the infoDict if required. We use this to rebuild audio links, exporter nodes and any other data that’s requried to be restored from the gathered info
self.animCache.infoDict
Parameters: feedback – data passed back into the call by the main loadAnimation func
-
<<<<<<< HEAD
loadAnimation
(filepath, incRoots=True, useFilter=True, loadAsStored=True, loadFromFrm=0, loadFromTimecode=False, timecodeBinding=[None, None], referenceNode=None, manageRanges=1, manageFileName=True, keyStatics=False, blendRange=0, *args, **kws)¶
=======
- : PRO_PACK :
- Binding of the animMap format for loading animation data from an r9Anim file. The base binding of the animation format is the DataMap object in the Red9_PoseSaver so many of the exposed flags come from there.
Parameters: - filepath – r9Anim file to load
- incRoots – do we include the root node in the load, in metaRig case this is ctrl_main
- useFilter – do we process all children of this rig or just selected
- loadAsStored – load the data from the timerange stored
- loadFromFrm – load the data from a given frame <<<<<<< HEAD
- loadFromTimecode – load against a given SMPTE timecode / frm binding, calculating the offset of the data to load against a given timecode reference. IF timecodeBinding isn’t set then we gather the reference timecode from the mRig’s internal data, else we use the timecode binding supplied
- timecodeBinding – (frm, str(‘00:00:00:00’)) Tuple where the first arg is the frame at which the second arg’s SMPTE timecode has been set as reference, basically we’re saying that the timecode at frm is x ======= >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
- referenceNode – load relative to the given node
- manageRanges – do we (0, 1, 2) = leave, extend or set the timeranges according to the anim data loaded
- manageFileName – if True and the current Maya scene has no filename other than a blank scene (ie freshly loaded rig) then we take the r9Anim’s filename and rename the Maya scene accordingly
- keyStatics – if True then we key everything in the data at startFrame so that all non-keyed and static attrs that are stored internally as a pose are keyed.
- blendRange – None or int : 1 is default. If an int is passed then we use this as the hold range for the data, setting a key at time=startFarme-blendRange to hold the current data before we load the new keys. Note that this also turns on the keyStatics to ensure the data is preserved
additional **KWS passed in and / or accepted in the ProPack codebase
KWS manageExport: If running the Red9Pro Exporter systems this will rebuild the export Tag data directly from the r9Anim file’s infoData block: False : don’t restore any exportData, [] : if you pass in a list then we take that list and match internal exportloop names to it ‘byName’ : restore only exportLoops who name matches the r9Anim’s name ‘byRange’: restore exportLoops that fall within the timerange of the imported r9Anim ‘byRange_start’ : restore exportLoops that start after the timerange of the importer r9Anim (ignore end time data) ‘byRange_end’ : restore exportLoops that end before the timerange of the importer r9Anim (ignore start time data) ‘byAll’ : restore ALL exportLoops in the r9Anim infoData block KWS manageAudio: If running the Red9Pro Exporter systems this will rebuild the Audio Node data directly from the r9Anim file’s infoData block (False, [], ‘byName’, ‘byRange’, ‘byRange_start’, ‘byRange_end’, ‘byAll’) Note
After the anim load the animData is stored on this instance as self.animMap which then exposes all the data for further functions if needed. self.animCache.infoDict = gatherInfo block on the file and pose self.animCache.poseDict = the animation and pose data dict
loadAnimation
(filepath, incRoots=True, useFilter=True, loadAsStored=True, loadFromFrm=0, referenceNode=None, manageRanges=1, manageFileName=True, keyStatics=False, blendRange=0, *args, **kws)¶ >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e-
Timecode
¶ : PRO_PACK : bind the Pro Timecode class to the node
-
timecode_get
(atFrame=None)¶ : PRO PACK : get the timecode object back from the rig
-
timecode_addAttrs
(tc='', propagate=False)¶ : PRO PACK : simple return to check if the system has the Pro Timecode systems bound to it
-
timecode_hasTimeCode
()¶ : PRO PACK : simple return to check if the system has the Pro Timecode systems bound to it
-
timecode_remove
()¶ : PRO PACK : simple return to check if the system has the Pro Timecode systems bound to it
-
class
MetaRigSubSystem
(*args, **kws)¶ Bases:
Red9.core.Red9_Meta.MetaRig
SubClass of the MRig, designed to organize Rig sub-systems (ie L_ArmSystem, L_LegSystem..) within a complex rig structure. This or MetaRig should have the Controllers wired to it
Idea here is if a MayaNode is passed in and has the mClass attr we pass that into the super(__new__) such that an object of that class is then instantiated and returned.
-
SupportNode
¶ return the connected Support mNode regardless of the wire used to connect it
Note
this is setup to use the Red9Pro Puppet wire conventions when multiple connected support nodes are found. The idea being that there is always 1 main support for a system and the naming convention of the mNodeID reflects that ie: L_ArmSystem and L_ArmSupport
-
-
class
MetaRigSupport
(*args, **kws)¶ Bases:
Red9.core.Red9_Meta.MetaClass
SubClass of MetaClass, designed to organize support nodes, solvers and other internal nodes within a complex rig structure which you may need to ID at a later date. Controllers should NOT be wired to this node
Idea here is if a MayaNode is passed in and has the mClass attr we pass that into the super(__new__) such that an object of that class is then instantiated and returned.
-
addSupportNode
(node, attr, boundData=None)¶ Add a single MAYA node flagged as a SUPPORT node of managed type
Parameters: - node – Maya node to add
- attr – Attr name to assign this too
- boundData – {} Data to set on the given node as attrs
-
-
class
MetaFacialRig
(*args, **kws)¶ Bases:
Red9.core.Red9_Meta.MetaRig
SubClass of the MetaRig, designed to be manage Facial systems in the MetaData Dag tree for organizing Facial Controllers and support nodes
Idea here is if a MayaNode is passed in and has the mClass attr we pass that into the super(__new__) such that an object of that class is then instantiated and returned.
-
class
MetaFacialRigSupport
(*args, **kws)¶ Bases:
Red9.core.Red9_Meta.MetaClass
SubClass of the MetaClass, designed to organize support nodes, solvers and other internal nodes within a complex rig structure which you may need to ID at a later date. Controllers should NOT be wired to this node
Idea here is if a MayaNode is passed in and has the mClass attr we pass that into the super(__new__) such that an object of that class is then instantiated and returned.
-
addSupportNode
(node, attr, boundData=None)¶ Add a single MAYA node flagged as a SUPPORT node of managed type.
Parameters: - node – Maya node to add
- attr – Attr name to assign this too
- boundData – {} Data to set on the given node as attrs
-
-
class
MetaHIKCharacterNode
(*args, **kws)¶ Bases:
Red9.core.Red9_Meta.MetaRig
Casting HIK directly to a metaClass so it’s treated as meta by default. Why the hell not, it’s a complex character node that is default in Maya and useful for management in the systems
Idea here is if a MayaNode is passed in and has the mClass attr we pass that into the super(__new__) such that an object of that class is then instantiated and returned.
-
isValid
()¶ simple check to see if this definition is still wired to a skeleton, the the skeleton was deleted then the definition never gets cleaned up!! Messy Sodding Maya!
-
getHIKPropertyStateNode
()¶ return the HIK Property node as a class for easy management
-
getHIKControlSetNode
()¶
-
delete
()¶ delete hik node and dependency nodes :return:
-
static
openui
()¶ Open hik UI
-
lock
()¶ lock hik characterisation :return: True if lock False if not lock
-
unLock
()¶ unlock hik characterisation
-
static
getCurrentCharacter
()¶ get current hik character :return: current hik charactre name
-
setascurrentcharacter
()¶ set current mNode as hikcurrentcharacter
-
checkcharacterization
()¶ check that hikNode characterisation is valid :return: True if valid False if invalid
-
-
class
MetaHIKControlSetNode
(*args, **kws)¶ Bases:
Red9.core.Red9_Meta.MetaRig
Casting HIK directly to a metaClass so it’s treated as meta by default. Why the hell not, it’s a complex character node that is default in Maya and useful for management in the systems
Idea here is if a MayaNode is passed in and has the mClass attr we pass that into the super(__new__) such that an object of that class is then instantiated and returned.
-
getHIKCharacterNode
()¶
-
getChildren
(walk=False, mAttrs=None, cAttrs=None)¶ Carefully over-loaded for HIK system
-
-
class
MetaHIKPropertiesNode
(*args, **kws)¶ Bases:
Red9.core.Red9_Meta.MetaClass
Casting HIK Properties to a Meta class for easy managing
Idea here is if a MayaNode is passed in and has the mClass attr we pass that into the super(__new__) such that an object of that class is then instantiated and returned.
-
monitorHUDaddCBAttrs
()¶ ChannelBox wrappers for the HUD : Adds selected attrs from the CB to a MetaHUD node for monitoring, if HUD node already exists this will simply add more attrs to it
-
monitorHUDManagement
(func)¶ ChannelBox wrappers for the HUD : kill any current MetaHUD headsUpDisplay blocks
-
monitorHUDremoveCBAttrs
()¶ ChannelBox wrappers for the HUD : remove attrs from the MetaHUD
-
hardKillMetaHUD
(*args)¶ If the MetaNodes are left behind in a scene and you can’t remove them then this is a hard coded kill to remove the hud element. This situation happens if you’d deleted the MetaHUDNode but left the draw on, meaning we now have invalid HUD data drawn.
-
class
MetaHUDNode
(*args, **kws)¶ Bases:
Red9.core.Red9_Meta.MetaClass
SubClass of the MetaClass, designed as a simple interface for HUD management in Maya. Any monitored attrs added to the MetaNode will show in the HUD when drawn.
The idea is that we have a single MetaNode with attrs that are monitored and managed for HUD display. To get an attr onto the HUD all you need to do is add it using addMonitoredAttr(), then drawHUD(). All I do is connect the HUD attr to the attr that you want to monitor, it just sits as a new wired node.
TODO: Look if we can link the Section and Block attrs to the refresh func via an attrChange callback Idea here is if a MayaNode is passed in and has the mClass attr we pass that into the super(__new__) such that an object of that class is then instantiated and returned.
-
addMonitoredAttr
(attr, value=None, attrType=None, refresh=True)¶ wrapper that not only adds an attr to the metaNode, but also adds it to the internal list of attributes that are monitored and added to the HUD when drawn.
Parameters: - attr – attr to be added to the node for monitoring in the HUD
- value – Initial value of the attr so the node can figure out what type of attr it is
- attrType – specifiy the attr type directly
- refresh – whether to refresh the HUD after adding a new attr
Note
this ties in with the default addAttr call hence the args are very similar in function
-
removeMonitoredAttr
(attr)¶ Remove an attr from the MetaNode and refresh the HUD to reflect the removal
Parameters: attr – attr to be removed from monitoring
-
getHudDisplays
()¶ each line in the HUD is actually a separate HUD in itself so we need to carefully manage this list
-
drawHUD
()¶ Push the monitored attrs up to the Maya HUD in the viewport
-
getConnectedAttr
(attr)¶
-
getConnectedNode
(attr)¶
-
setSlidertoAttr
(slider, attr)¶
-
resetSlider
(slider, attr)¶ If the HUD is made up of sliders this resets them
Parameters: - slider – slider to reset in the HUD
- attr – attr to reset on the mNode
-
showHud
(value)¶ manage the visibility state of the HUD
Parameters: value – show or hide the HUD
-
killHud
()¶ kill the HUD display altogether
-
refreshHud
()¶ Refresh the HUD by killing it and re-drawing it from scratch
-
delete
()¶ full cleanup, remove the metaNode and all HUDs in the process
-
-
class
MetaTimeCodeHUD
(*args, **kws)¶ Bases:
Red9.core.Red9_Meta.MetaHUDNode
Generate’s a HUD node connected to the main timecode attrs, allows us to show the actual internal timecode attrs as their original SMPTE time’s
Crucial things to be aware of:
We construct timecode from 3 attrs on the given node: timecode_ref : the original timecode converted to milliseconds timecode_count : a linear curve that increments every frame based on the samplerate timecode_samplerate : samplerate that the linear counter was generated against
SMPTE timecode is then reconstructed like so:
>>> r9Audio.milliseconds_to_Timecode(ref + ((count / samplerate) * 1000)) >>> >>> tcHUD=cFacialMeta.MetaTimeCodeHUD() >>> tcHUD.addMonitoredTimecodeNode(cmds.ls(sl=True)[0]) >>> tcHUD.drawHUD()
Idea here is if a MayaNode is passed in and has the mClass attr we pass that into the super(__new__) such that an object of that class is then instantiated and returned.
-
addMonitoredTimecodeNode
(nodes, valid=True)¶ add a node with the TimeCode attrs on it to monitor
-
removeMonitoredAttr
(attr)¶
-
connectTimecodeSystems
(*args, **kws)¶
-
-
metaData_sceneCleanups
(*args)¶ Registered on SceneOpen and SceneNew callbacks so that the MetaData Cache is cleared and any registered HUD is killed off
-