Пример #1
0
 def bnn_find(cls, pattern=''):
     """Find DAG nodes.
     
     Parameters
     ----------
     pattern : str, optional
         Name or path pattern of the DAG nodes to match.
         Wildcards are allowed.
     
     Returns
     -------
     list of calling class
         The DAG nodes found. If no nodes were found, an empty
         list is returned.
     """
     iterator = OpenMaya.bnn_MItDagNode(pattern=pattern, types=cls().type())
     return [cls(dagPath) for dagPath in iterator]
Пример #2
0
 def bnn_find(cls, pattern='', types=None):
     """Find DAG nodes.
     
     Parameters
     ----------
     pattern : str, optional
         Name or path pattern of the DAG nodes to match.
         Wildcards are allowed.
     types : list of maya.OpenMaya.MFn.Type, optional
         Node types to match.
     
     Returns
     -------
     list of maya.OpenMaya.MDagPath
         The DAG path objects of the nodes found. If no nodes were
         found, an empty list is returned.
     """
     return list(OpenMaya.bnn_MItDagNode(pattern=pattern, types=types))
Пример #3
0
 def bnn_get(cls, pattern, types=None):
     """Retrieve a DAG node.
     
     Parameters
     ----------
     pattern : str
         Name or path pattern of the DAG node to match.
         Wildcards are allowed.
     types : list of maya.OpenMaya.MFn.Type, optional
         Node types to match.
     
     Returns
     -------
     maya.OpenMaya.MDagPath
         The DAG path object of the node matched. If no or multiple
         nodes were found, None is returned.
     
     Examples
     --------
     Retrieve a DAG path object from its name:
     
     >>> import banana.maya
     >>> banana.maya.patch()
     >>> from maya import OpenMaya, cmds
     >>> cmds.polyCube(name='cube')
     >>> cube = OpenMaya.MDagPath.bnn_get('cube')
     """
     iterator = OpenMaya.bnn_MItDagNode(pattern=pattern, types=types)
     dagPath = None
     for item in iterator:
         if dagPath:
             return None
         
         dagPath = item
     
     return dagPath