Meta Node Network¶
Base¶
The module deals with meta data in maya scenes by adding attributes to nodes and providing quick and easy query features. Everything is built with the maya python 2.0 to make queries and creation as fast as possible. Graph Traversal methods works by walking the dependency graph by message attributes.
@todo: may need to create a scene cache with a attach node callback to remove node form the cache
- findSceneRoots()¶
Finds all meta nodes in the scene that are root meta node
- Returns:
- Return type:
list()
- metaNodeByName(name)¶
Gets meta node by given name
- metaNodeByHandle(handle)¶
Gets meta node by given name
- filterSceneByAttributeValues(attributeNames, filter)¶
From the all scene zoo meta nodes find all attributeNames on the node if the value of the attribute is a string the filter acts as a regex otherwise it’ll will do a value == filter op.
- Parameters:
attributeNames (seq(str)) – a list of attribute name to find on each node
filter (any maya datatype) – filters the found attributes by value
- Returns:
A seq of plugs
- Return type:
seq(MPlug)
- iterSceneMetaNodes()¶
Iterates all meta nodes in the maya scene.
- Return type:
- findMetaNodesByClassType(classType)¶
Finds and returns all meta nodes in the scene that are of the given class type.
- metaFromHandles(handles)¶
Get Meta nodes from MObjectHandles
- Parameters:
handles (list[om2.MObjectHandle]) – List of MObjectHandles to retrieve the metanodes from
- Returns:
List of Metanodes
- Return type:
- metaNodeFromZApiObjects(objects)¶
Converts the specified zapi objects to meta node classes.
- Parameters:
objects (list[
zapi.DGNode
]) –- Returns:
- Return type:
list[
MetaBase
]
- findRelatedMetaNodesByClassType(relatedNodes, classType)¶
From a list of Maya zapi nodes returns the meta node classes matching by string type:
Checks if attribute value of zooMClass matches the string MClassValue
- Parameters:
relatedNodes (list(
zapi.DGNode
)) – any maya nodes by name, should be joints or curves related to joint setupclassType (str) – The attribute value of the meta node Maya attr “zooMClass”
- Return metaNodeList:
A list of metaNode objects
- Rtype metaNodeList:
list(
base.MetaBase
)
- isMetaNodeOfTypes(node, classTypes)¶
Checks whether the provided node is a meta node of the specified types.
- isMetaNode(node)¶
Determines if the node is a meta node by seeing if the attribute mnode exists and mclass value(classname) is within the current meta registry
- Parameters:
node (
zapi.DGNode
) – The node to check- Return type:
- isConnectedToMeta(node)¶
Determines if the node is directly connected to a meta node by searching upstream of the node
- Parameters:
node –
zapi.DGNode
- Return type:
- getUpstreamMetaNodeFromNode(node)¶
Returns the upstream meta node from node expecting the node to have the metaNode attribute
- Parameters:
node (
zapi.DGNode
) – the api node to search from- Return type:
- getConnectedMetaNodes(node)¶
Returns all the downStream connected meta nodes of ‘mObj’
- Parameters:
node (
zapi.DGNode
) – The meta node MObject to search- Returns:
A list of MetaBase instances, each node will have its own subclass of metabase returned.
- Return type:
list[
MetaBase
]
- createNodeByType(typeName, *args, **kwargs)¶
Creates and returns the type class instance from the meta registry this will also create the node in the scene.
- class MetaRegistry(*args, **kwargs)¶
Bases:
object
Singleton class to handle global registration to meta classes
- metaEnv = 'ZOO_META_PATHS'¶
- types = {}¶
- reload()¶
- classmethod isInRegistry(typeName)¶
Checks to see if the type is currently available in the registry
- classmethod getType(typeName)¶
Returns the class of the type
- classmethod registerMetaClasses(paths)¶
This function is helper function to register a list of paths.
- Parameters:
paths (list(str)) – A list of module or package paths, see registerByModule() and registerByPackage() for the path format.
- classmethod registerByModule(module)¶
This function registry a module by search all class members of the module and registers any class that is an instance of the plugin class
- Parameters:
module (str) – the module path to registry
- classmethod registerByPackage(pkg)¶
This function is similar to registerByModule() but works on packages, this is an expensive operation as it requires a recursive search by importing all sub modules and and searching them.
- Parameters:
pkg (str) – The package path to register eg. zoo.libs.apps
- class MetaFactory¶
Bases:
type
MetaClass for metabase class to create the correct metaBase subclass based on class plug name if a meta node(MObject) exists in the arguments
- registryNameForClass(classType)¶
Returns the registry name for the class type, this is the class name or the id if it exists. The ID is preferred of the class name.
- class MetaBase(*args, **kwargs)¶
Bases:
DGNode
- icon = 'networking'¶
- id = ''¶
- static classNameFromPlug(node)¶
Given the MObject node or metaClass return the associated class name which should exist on the maya node as an attribute
- Parameters:
node (MObject or MetaBase instance) – the node to find the class name for
- Returns:
the mClass name
- Return type:
- purgeMetaAttributes()¶
- metaAttributes()¶
- metaAttributeValues()¶
Get the Meta attributes values
- Returns:
Meta attribute values
- Return type:
- isRoot()¶
- mClassType()¶
- delete(mod=None, apply=True)¶
Overloaded function to disconnect child meta nodes before deleting
- Parameters:
mod (
om2.MDGModifier
or om2.MDagModifier) – Modifier to add the delete toapply (bool) – Apply the modifier immediately if true, false otherwise
- findConnectedNodesByAttributeName(filter, recursive=False)¶
- findPlugsByFilteredName(filter='')¶
Finds all plugs with the given filter with in name
- Parameters:
filter (str) – the string the search the names by
- Returns:
A seq of MPlugs
- Return type:
seq(MPlug)
- connectTo(attributeName, node)¶
Connects one plug to another by attribute name
- Parameters:
attributeName (str) – the meta attribute name to connect from, if it doesn’t exist it will be created
node (MObject) – the destination node
- Returns:
the destination plug
- Return type:
om2.MPlug
- connectToByPlug(destinationPlug, node)¶
- metaRoot()¶
- metaParents(recursive=False)¶
- iterMetaParents(recursive=False)¶
- iterChildren(fnFilters=None, includeMeta=False)¶
- iterMetaChildren(depthLimit=256)¶
This function iterate the meta children by the metaChildren Plug and return the metaBase instances
- metaChildren(depthLimit=256)¶
This function iterate the meta children by the metaChildren Plug and return the metaBase instances
- iterMetaTree(depthLimit=256)¶
This function traverses the meta tree pulling out any meta node this is done by checking each node has the mclass Attribute. This function can be slow depending on the size of the tree
- addMetaChild(child, mod=None)¶
Add meta child
- Parameters:
child (
MetaBase
) –mod (
maya.api.OpenMaya.MDagModifier or maya.api.OpenMaya.MDGModifier
) –
- addMetaParent(parent, mod=None)¶
Sets the parent meta node for this node, removes the previous parent if its attached
- Parameters:
parent (MetaBase) – The meta node to add as the parent of this meta node
mod (
maya.api.OpenMaya.MDagModifier or maya.api.OpenMaya.MDGModifier
) –
- attributeNodes(attrPlug)¶
Returns a list of dag/dg nodes from the given meta attribute plug.
- Returns:
list of zapi nodes
- Return type:
list(
zapi.DGNode
)
- findChildrenByFilter(filter, plugName=None, depthLimit=256)¶
- findChildrenByClassType(classType, depthLimit=1)¶
Find’s all meta children of a certain type.
- findChildrenByClassTypes(classTypes, depthLimit=1)¶
Find’s all meta children of a certain type.
- findChildByType(Type)¶
- allChildrenNodes(recursive=False, includeMeta=False)¶
- removeParent(parent=None, mod=None)¶
Remove Parent
- removeAllParents()¶
- classmethod connectedMetaNodes(node)¶
Returns the meta nodes if it’s the same class type
- Parameters:
node (
zapi.DagNode
) –