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

Parameters:

name (str) – The name of the metanode to look for

Returns:

Meta node

Return type:

MetaBase

metaNodeByHandle(handle)

Gets meta node by given name

Parameters:

handle (str) – The MObjectHandle of the node to convert to it’s meta node class if possible.

Returns:

Meta node

Return type:

MetaBase

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:

collections.Iterable[MetaBase]

findMetaNodesByClassType(classType)

Finds and returns all meta nodes in the scene that are of the given class type.

Parameters:

classType (str) – The class type to find.

Return type:

list[MetaBase]

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:

list[zoo.libs.maya.meta.base.MetaBase]

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 setup

  • classType (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.

Parameters:
  • node (zapi.DGNode) – The node to check

  • classTypes (tuple[str]) – The meta system registered class types.

Return type:

bool

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:

bool

isConnectedToMeta(node)

Determines if the node is directly connected to a meta node by searching upstream of the node

Parameters:

nodezapi.DGNode

Return type:

bool

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:

MetaBase

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.

Parameters:
  • typeName (str) – The Class Type name in the registry

  • args (tuple) – The args to pass to the class.__init__

  • kwargs (dict) – keywords to pass to the class.__init__

Returns:

MetaBase, subclass of MetaBase for the type

Return type:

MetaBase or None

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

Parameters:

typeName (str) – the class name

Returns:

returns the class object for the given type name

Return type:

MetaBase

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

classmethod registryByEnv(env)

Register a set of meta class by environment variable

Parameters:

env (str) – the environment variable name

classmethod registerMetaClass(classObj)

Registers a plugin instance to the manager

Parameters:

classObj (Plugin) – the metaClass to registry

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.

Parameters:

classType (MetaBase) – The class object or instance to get the registry name for.

Returns:

The class type id.

Return type:

str

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:

str

purgeMetaAttributes()
metaAttributes()
metaAttributeValues()

Get the Meta attributes values

Returns:

Meta attribute values

Return type:

dict

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 to

  • apply (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, visited=None)

This function iterates the meta children by the metaChildren Plug and returns the metaBase instances

Parameters:

depthLimit (int) – The traversal depth limit

Returns:

A list of Metabase instances

Return type:

list(MetaBase)

metaChildren(depthLimit=256, visited=None)

This function iterates the meta children by the metaChildren Plug and returns the metaBase instances

Parameters:

depthLimit (int) – The traversal depth limit

Returns:

A list of Metabase instances

Return type:

list(MetaBase)

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

Parameters:

depthLimit (int) –

Return type:

generator(MetaBase)

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.

Parameters:
  • classType (str) – The zoo meta class type name.

  • depthLimit (int) – The recursive depth limit, defaults to a depth of 1.

Returns:

An iterable of metaBase instances.

Return type:

iterable[MetaBase]

findChildrenByClassTypes(classTypes, depthLimit=1)

Find’s all meta children of a certain type.

Parameters:
  • classTypes (iterable[str]) – The zoo meta class type name.

  • depthLimit (int) – The recursive depth limit, defaults to a depth of 1.

Returns:

An iterable of metaBase instances.

Return type:

iterable[MetaBase]

findChildByType(Type)
allChildrenNodes(recursive=False, includeMeta=False)
removeParent(parent=None, mod=None)

Remove Parent

Parameters:

parent (MetaBase or None) – The meta class to remove, if set to None then all parents will be removed

Return type:

bool

removeAllParents()
classmethod metaNodesInScene()

List of metanodes of same type

Returns:

Return type:

list[MetaBase]

classmethod connectedMetaNodes(node)

Returns the meta nodes if it’s the same class type

Parameters:

node (zapi.DagNode) –

isClassType(metaBase)

Returns true if is class type

Parameters:

metaBase (Type[MetaBase]) –

Returns:

Return type: