Package mrv :: Package maya :: Package nt :: Module it
[hide private]
[frames] | no frames]

Module it

source code

Contains different multi-purpose iterators allowing to conveniently walk the dg and dag.
Functions [hide private]
 
_argsToFilter(args)
convert the MFnTypes in args list to the respective typeFilter
source code
 
iterDgNodes(*args, **kwargs)
Iterator on MObjects or Nodes of the specified api.MFn types
source code
 
iterDagNodes(*args, **kwargs)
Iterate over the hierarchy under a root dag node, if root is None, will iterate on whole Maya scene If a list of types is provided, then only nodes of these types will be returned, if no type is provided all dag nodes under the root will be iterated on.
source code
 
iterGraph(nodeOrPlug, *args, **kwargs)
Iterate Dependency Graph (DG) Nodes or Plugs starting at a specified root Node or Plug.
source code
 
iterSelectionList(sellist, filterType=api.MFn.kInvalid, predicate=lambda x: True, asNode=True, handlePlugs=True, handleComponents=False)
Iterate the given selection list
source code
    Iterator Creators
 
dgIterator(*args, **kwargs)
Returns: MItDependencyNodes configured according to args - see docs at iterDgNodes.
source code
 
dagIterator(*args, **kwargs)
Returns: MItDagIterator configured according to args - see docs at iterDagNodes.
source code
 
graphIterator(nodeOrPlug, *args, **kwargs)
Returns: MItDependencyGraph configured according to args - see docs at iterGraph.
source code
 
selectionListIterator(sellist, **kwargs)
Returns: iterator suitable to iterate given selection list - for more info see iterSelectionList
source code
Variables [hide private]
  nullplugarray = api.MPlugArray()
Function Details [hide private]

dgIterator(*args, **kwargs)

source code 
Returns:
MItDependencyNodes configured according to args - see docs at iterDgNodes.

Note: use this method if you want to use more advanced features of the iterator

dagIterator(*args, **kwargs)

source code 
Returns:
MItDagIterator configured according to args - see docs at iterDagNodes.

Note: use this method if you want to use more advanced features of the iterator

graphIterator(nodeOrPlug, *args, **kwargs)

source code 
Returns:
MItDependencyGraph configured according to args - see docs at iterGraph.
Raises:
  • RuntimeError - if the filter types does not allow any nodes to be returned. This is a bug in that sense as it should just return nothing. It also shows that maya pre-parses the result and then just iterates over a list with the iterator in question

Note: use this method if you want to use more advanced features of the iterator

selectionListIterator(sellist, **kwargs)

source code 
Returns:
iterator suitable to iterate given selection list - for more info see iterSelectionList

iterDgNodes(*args, **kwargs)

source code 
Iterator on MObjects or Nodes of the specified api.MFn types
Parameters:
  • args - type as found in MFn.k... to optionally restrict the set of nodes the iterator operates upon. All nodes of a type included in the args will be iterated on. args is empty, all nodes of the scene will be iterated on which may include DAG nodes as well.
  • kwargs -
    • asNode:

      if True, default True, the returned value will be wrapped as node

    • predicate:

      returns True for every iteration element that may be returned by the iteration, default : lambda x: True

iterDagNodes(*args, **kwargs)

source code 
Iterate over the hierarchy under a root dag node, if root is None, will iterate on whole Maya scene If a list of types is provided, then only nodes of these types will be returned, if no type is provided all dag nodes under the root will be iterated on. Types are specified as Maya API types being a member of api.MFn The following keywords will affect order and behavior of traversal:
Parameters:
  • kwargs -
    • dagpath:

      if True, default True, MDagPaths will be returned If False, MObjects will be returned - it will return each object only once in case they occour in multiple paths.

    • depth:

      if True, default True, Nodes will be returned as a depth first traversal of the hierarchy tree if False as a post-order (breadth first)

    • underworld:

      if True, default False, traversal will include a shape's underworld (dag object parented to the shape), if False the underworld will not be traversed,

    • asNode:

      if True, default True, the returned item will be wrapped into a Node

    • root:

      MObject or MDagPath or Node of the object you would like to start iteration on, or None to start on the scene root. The root node will also be returned by the iteration ! Please note that if an MObject is given, it needs to be an instanced DAG node to have an effect.

    • predicate:

      method returning True if passed in iteration element can be yielded default: lambda x: True

iterGraph(nodeOrPlug, *args, **kwargs)

source code 
Iterate Dependency Graph (DG) Nodes or Plugs starting at a specified root Node or Plug. The iteration _includes_ the root node or plug. The following keywords will affect order and behavior of traversal:
Parameters:
  • nodeOrPlug - Node, MObject or MPlug to start the iteration at
  • args - list of MFn node types If a list of types is provided, only nodes of these types will be returned, if no type is provided all connected nodes will be iterated on.
  • kwargs -
    • input:

      if True connections will be followed from destination to source, if False from source to destination default is False (downstream)

    • breadth:

      if True nodes will be returned as a breadth first traversal of the connection graph, if False as a preorder (depth first) default is False (depth first)

    • plug:

      if True traversal will be at plug level (no plug will be traversed more than once), if False at node level (no node will be traversed more than once), default is False (node level)

    • prune:

      if True, the iteration will stop on nodes that do not fit the types list, if False these nodes will be traversed but not returned default is False (do not prune)

    • asNode:

      if True, default True, and if the iteration is on node level, Nodes ( wrapped MObjects ) will be returned If False, MObjects will be returned

    • predicate:

      method returning True if passed in iteration element can be yielded default: lambda x: True

Returns:
Iterator yielding MObject, Node or Plug depending on the configuration flags, first yielded item is always the root node or plug.

iterSelectionList(sellist, filterType=api.MFn.kInvalid, predicate=lambda x: True, asNode=True, handlePlugs=True, handleComponents=False)

source code 
Iterate the given selection list
Parameters:
  • sellist - MSelectionList to iterate
  • filterType - MFnType id acting as simple type filter to ignore all objects which do not have the given object type
  • asNode - if True, returned MObjects or DagPaths will be wrapped as Node, compoents will be wrapped as Component. Otherwise they will be returned as MObjects and MDagPaths respectively.
  • handlePlugs - if True, plugs can be part of the selection list and will be returned. This implicitly means that the selection list will be iterated without an iterator, and MFnType filters will be slower as it is implemented in python. If components are enabled, the tuple returned will be ( Plug, MObject() )
  • predicate - method returninng True if passed in iteration element can be yielded default: lambda x: True
  • handleComponents - if True, possibly selected components of dagNodes will be returned as well. This forces the return value into tuple(Node, Component)
Returns:
Node or Plug on each iteration step If handleComponents is True, for each Object, a tuple will be returned as tuple( Node, Component ) where component is NullObject ( MObject ) if the whole object is on the list. If the original object was a plug, it will be in the tuples first slot, whereas the component will be a NullObject