mrv.maya.nt.geometry

Epydoc: mrv.maya.nt.geometry

Contains implementations ( or improvements ) to mayas geometric shapes

Functions

Classes

Epydoc: mrv.maya.nt.geometry.ControlPoint

class mrv.maya.nt.geometry.ControlPoint

Bases: mrv.maya.nt.DeformableShape

addAttribute(attr)

Add the given attribute to the node as local dynamic attribute

Parameter:attr – MObject of attribute or Attribute instance as retrieved from a plug
Returns:plug to the newly added attribute
Note:This method is explicitly not undoable as attributes are being deleted in memory right in the moment they are being removed, thus they cannot reside on the undo queue
addChild(*args, **kwargs)

Add the given childNode as child to this Node. Allows instancing !

Parameters:
  • childNode – Node you wish to add
  • position – the index to which to add the new child, kNextPos will add it as last child. It supports python style negative indices
  • keepExistingParent – if True, the childNode will be instanced as it will have its previous parent(s) and this one, if False, the previous parent will be removed from the child’s parent list
  • renameOnClash – resolve nameclashes by automatically renaming the node to make it unique
  • keepWorldSpace – see reparent, only effective if the node is not instanced
Returns:

childNode whose path is pointing to the new child location

Raises ValueError:
 

if keepWorldSpace is requested with directly instanced nodes

Note:

as maya internally handles add/remove child as instancing operation, even though keepExistingParent is False, it will mess up things and for a short period of time in fact have two n + 1 instances, right before one is unlinked, This still fills a slot or something, and isInstanced will be true, although the pathcount is 1. Long story short: if the item to be added to us is not instanced, we use reparent instead. It will not harm in direct instances, so its save to use.

Note:

if the instance count of the item is 1 and keepExistingParent is False, the position argument is being ignored

addInstancedChild(*args, **kwargs)

Add childnode as instanced child to this node

Note:for more information, see addChild
Note:its a shortcut to addChild allowing to clearly indicate what is happening
addParent(*args, **kwargs)

Adds ourselves as instance to the given parentnode at position

Parameter:kwargs – see addChild
Returns:self with updated dag path
classmethod addSep(item, sep)
Returns:

item with separator added to it ( just once )

Note:

operates best on strings

Parameters:
  • item – item to add separator to
  • sep – the separator
addTo(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5c828e0> >, **kwargs)

Add ourselves to the given set

Note:method is undoable
See:sets.ObjectSet
allocateFlag()
apiObject()
Returns:our dag path as this is our api object - the object defining this node best
apiType()
Returns:the MFn Type id of the wrapped object
basename()
Returns:basename of this path, ‘/hello/world’ -> ‘world’
child(index)
Returns:child of self at index
Note:this method fixes the MFnDagNode.child method - it returns an MObject, which doesnt work well with instanced nodes - a dag path is required, which is what we use to aquire the object
childTransforms(predicate=<function <lambda> at 0x5e9b2a8>)
Returns:list of all transform nodes below this one
children(predicate=<function <lambda> at 0x5e99f50>, asNode=True)
Returns:all child nodes below this dag node if predicate returns True for passed Node
Parameter:asNode – if True, you will receive the children as wrapped Nodes, otherwise you get MDagPaths
childrenByType(nodeType, predicate=<function <lambda> at 0x5e9b0c8>)
Returns:all childnodes below this one matching the given nodeType and the predicate
Parameter:nodeType – class of the nodeTyoe, like nt.Transform
childrenDeep(order=1, predicate=<function <lambda> at 0x7f41dd7c5050>)
Returns:

list of all children of path, [ child1 , child2 ]

Parameters:
  • order – order enumeration
  • predicate – returns true if x may be returned
Note:

the child objects returned are supposed to be valid paths, not just relative paths

className()
classification()
componentAssignments(setFilter=(319, False, 0), use_api=True, asComponent=True)
Returns:

list of tuples(ObjectSetNode, Component_or_MObject) defininmg shader assignments on per component basis.

If a shader is assigned to the whole object, the component would be a null object, otherwise it is an instance of a wrapped IndexedComponent class

Note:

The returned Component will be an MObject(kNullObject) only in case the component is not set. Hence you should check whether it isNull() before actually using it.

Parameters:
  • setFilter – see connectedSets
  • use_api – if True, api methods will be used if possible which is usually faster. If False, a custom non-api implementation will be used instead. This can be required if the apiImplementation is not reliable which happens in few cases of ‘weird’ component assignments
  • asComponent – If True, the components will be wrapped into the matching MRV compontent type to provide a nicer interface. This might slightly slow down the process, but this is usually neglectable.
Note:

the sets order will be the order of connections of the respective component list attributes at instObjGroups.objectGroups

Note:

currently only meshes and subdees support per component assignment, whereas only meshes can have per component shader assignments

Note:

SubDivision Components cannot be supported as the component type kSubdivCVComponent cannot be wrapped into any component function set - reevaluate that with new maya versions !

Note:

deformer set component assignments are only returned for instance 0 ! They apply to all output meshes though

connectedSets(setFilter=(459, False, 0))
Returns:list of object set compatible Nodes having self as member
Parameter:setFilter – tuple(apiType, use_exact_type) - the combination of the desired api type and the exact type flag allow precise control whether you which to get only renderable shading engines, only objectfSets (tuple[1] = True), or all objects supporting the given object type. Its preset to only return shading engines
Note:the returned sets order is defined by the order connections to instObjGroups
Note:only sets will be returned that have the whole object as member, thus you will not see sets having component assignments like per-compoent shader assignments or deformer sets
connections()
Returns:MPlugArray of connected plugs
copyFrom(other, *args, **kwargs)

Copy the data from other into self as good as possible Only copy the data that is unique to your specific class - the data of other classes will be taken care of by them !

Note:you must support args and kwargs if one of your iDuplicate bases does

Copy lightlinks from one meshShape to another

Parameter:kwargs
  • substitute:
    if True, default False, the other shape will be put in place of self, effectively receiving it’s light-links whereas self losses them. This is practical in case you create a new shape below a transform that had a previously visible and manipulated shape whose external connections you wouuld like to keep
copyTo(instance, *args, **kwargs)

Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance

Returns:altered instance
Note:instance will be altered during the process
copyToOther(instance, *args, **kwargs)
As copyTo, but does only require the objects to have a common base. It will match the actually compatible base classes and call copyFrom if possible. As more checking is performed, this method performs worse than copyTo
createInstance(*args, **kwargs)

Create and Initialize an instance of self.__class__( ... ) based on your own data

Returns:new instance of self
Note:using self.__class__ instead of an explicit class allows derived classes that do not have anything to duplicate just to use your implementeation
Note:you must support args and kwargs if one of your iDuplicate bases does
dagPath()
Returns:the original DagPath attached to this Node - it’s not wrapped for performance
Note:If you plan to alter it, make sure you copy it using the MDagPath(node.dagPath()) construct !
deallocateAllFlags()
deallocateFlag()
delete(*args, **kwargs)

Delete this node - this special version must be

Note:if the undo queue is enabled, the object becomes invalid, but stays alive until it drops off the queue
Note:if you want to delete many nodes, its more efficient to delete them using the global delete method
dependencyInfo(attribute, by=True)
Returns:

list of attributes that given attribute affects or that the given attribute is affected by if the attribute turns dirty.

Parameters:
  • attribute – attribute instance or attribute name
  • by – if false, affected attributes will be returned, otherwise the attributes affecting this one
Note:

see also MPlug.affectedByPlugs

Note:

USING MEL: as api command and mObject array always crashed on me ... don’t know :(

displayOverrideValue(plugName)
Returns:the override display value actually identified by plugName affecting the given object (that should be a leaf node for the result you see in the viewport. The display type in effect is always the last one set in the hierarchy returns None display overrides are disabled
duplicate(*args, **kwargs)

Duplciate the given node to newpath

Parameters:
  • newpath

    result depends on its format:

    • ‘’ - empty string, creates a unique name based on the actual node name by appending a copy number to it, if newTransform is True, the newly created shape/transform will keep its name, but receives a new parent
    • ‘newname’ - relative path, the node will be duplicated not changing its current parent if newTransform is False
    • |parent|newname - absolute path, the node will be duplicated and reparented under the given path
      if newTransform is True, a new transform name will be created based on your name by appending a unique copy number
  • autocreateNamespace – if true, namespaces given in newpath will be created automatically, otherwise a RuntimeException will be thrown if a required namespace does not exist
  • renameOnClash – if true, clashing names will automatically be resolved by adjusting the name
  • newTransform – if True, a new transform will be created based on the name of the parent transform of this shape node, appending a unique copy number to it. Only has an effect for shape nodes
Returns:

newly create Node

Note:

duplicate performance could be improved by checking more before doing work that does not really change the scene, but adds undo operations

Note:

inbetween parents are always required as needed

Todo:

add example for each version of newpath

Note:

instancing can be realized using the addChild function

Note:

If meshes have tweaks applied, the duplicate will not have these tweaks and the meshes will look mislocated. Using MEL works in that case ... (they fixed it there obviously) , but creates invalid objects

Todo:

Undo implementation - every undoable operation must in fact be based on strings to really work, all this is far too much - dagNode.duplicate must be undoable by itself

Todo:

duplicate should be completely reimplemented to support all mel options and actually work with meshes and tweaks - the underlying api duplication would still be used of course, as well as connections (to sets) and so on ...

fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
classmethod getMFnClasses()
Returns:list of all function set classes this node supports, most derived function set comes first
hasChild(node)
Returns:True if node is a child of self
hasFn(mfntype)
Returns:True if our object supports the given function set type
instance(instanceNumber)
Returns:Node to the instance identified by instanceNumber
Parameter:instanceNumber – range(0, self.instanceCount()-1)
instanceNumber()
Returns:our instance number
Note:0 does not indicate that this object is not instanced - use getInstanceCount instead
isAlive()
Returns:True if the object exists in memory
Note:objects on the undo queue are alive, but NOT valid
isMemberOf(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5c1d740> >)
Returns:True if self is part of setnode
Note:method is undoable
See:sets.ObjectSet
isPartOf(other)
Returns:True if self is a part of other, and thus can be found in other
Note:operates on strings only
isRoot()
Returns:True if this path is the root of the DAG
isRootOf(other)
Returns:True other starts with self
Note:operates on strings
Note:we assume other has the same type as self, thus the same separator
isTemplate()
Returns:True if this node is templated - this is the case if itself or one of its parents are templated
isValid()
Returns:True if the object exists in the scene
Note:Handles DAG objects correctly that can be instanced, in which case the MObject may be valid , but the respective dag path is not. Additionally, if the object is not parented below any object, everything appears to be valid, but the path name is empty
isVisible()
Returns:True if this node is visible - its visible if itself and all parents are visible
iterInstances(excludeSelf=False)

Get iterator over all (direct and indirect)instances of this node

Parameter:excludeSelf – if True, self will not be returned, if False, it will be in the list of items
Note:Iterating instances is more efficient than querying all instances individually using instance
Todo:add flag to allow iteration of indirect instances as well
iterParents(predicate=<function <lambda> at 0x7f41dd7c5230>)
Returns:generator retrieving all parents up to the root
Parameter:predicate – returns True for all x that you want to be returned
name()
Returns:fully qualified (long) name of this dag node
object()
Returns:MObject as retrieved from the MDagPath of our Node
parent()
Returns:Maya node of the parent of this instance or None if this is the root
parentAtIndex(index)
Returns:Node of the parent at the given index - non-instanced nodes only have one parent
Note:if a node is instanced, it can have parentCount parents
Todo:Update dagpath afterwards ! Use dagpaths instead !
parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
referenceFile()
Returns:name (str) of file this node is coming from - it could contain a copy number as {x}
Note:will raise if the node is not referenced, use isReferenced to figure that out
removeAttribute(attr)

Remove the given attribute from the node

Parameter:attr – see addAttribute
removeChild(*args, **kwargs)

remove the given childNode (being a child of this node) from our child list, effectively parenting it under world !

Parameters:
  • childNode – Node to unparent - if it is not one of our children, no change takes place
  • allowZeroParents – if True, it is possible to leave a node unparented, thus no valid dag paths leads to it. If False, transforms will just be reparented under the world
Returns:

copy of childnode pointing to the first valid dag path we find.

Note:

to prevent the child (if transform) to dangle in unknown space if the last instance is to be removed, it will instead be reparented to world.

Note:

removing shapes from their last parent will result in an error

removeFrom(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5b41420> >)

remove ourselves to the given set

Note:method is undoable
See:sets.ObjectSet
removeParent(*args, **kwargs)

Remove ourselves from given parentnode

Returns:None
rename(*args, **kwargs)

Rename this node to newname

Parameters:
  • newname – new name of the node
  • autocreateNamespace – if true, namespaces given in newpath will be created automatically, otherwise a RuntimeException will be thrown if a required namespace does not exist
  • renameOnClash – if true, clashing names will automatically be resolved by adjusting the name
Returns:

renamed node which is the node itself

Note:

for safety reasons, this node is dagnode aware and uses a dag modifier for them !

reparent(*args, **kwargs)

Change the parent of all nodes (also instances) to be located below parentnode

Parameters:
  • parentnode – Node instance of transform under which this node should be parented to if None, node will be reparented under the root (which only works for transforms)
  • renameOnClash – resolve nameclashes by automatically renaming the node to make it unique
  • raiseOnInstance – if True, this method will raise if you try to reparent an instanced object. If false, instanced objects will be merged into the newly created path under parentnode, effectively eliminating all other paths , keeping the newly created one
  • keepWorldSpace – if True and node to be reparented is a transform, the world space position will be kept by adjusting the transformation accordingly. WARNNG: Currently we reset pivots when doing so

:return : copy of self pointing to the new dag path self

Note:will remove all instance of this object and leave this object at only one path - if this is not what you want, use the addChild method instead as it can properly handle this case
Note:this method handles namespaces properly
root()
Returns:the root of the DAG - it has no further parents
setLocked(*args, **kwargs)

Lock or unloack this node

Parameter:state – if True, the node is locked. Locked nodes cannot be deleted, renamed or reparented
Note:you can query the lock state with isLocked
setNamespace(*args, **kwargs)
Returns:

self after being moved to the given namespace. This will effectively rename the object.

Parameters:
  • newns – Namespace instance to put this Node into
  • kwargs – to be passed to rename
setParent(*args, **kwargs)

Change the parent of self to parentnode being placed at position

Parameter:kwargs – see addChild
Returns:self with updated dag path
sets(setFilter=(459, False, 0))
Returns:list of object set compatible Nodes having self as member
Parameter:setFilter – tuple(apiType, use_exact_type) - the combination of the desired api type and the exact type flag allow precise control whether you which to get only renderable shading engines, only objectfSets (tuple[1] = True), or all objects supporting the given object type. Its preset to only return shading engines
Note:the returned sets order is defined by the order connections to instObjGroups
Note:only sets will be returned that have the whole object as member, thus you will not see sets having component assignments like per-compoent shader assignments or deformer sets
shapes(predicate=<function <lambda> at 0x5e9b1b8>)
Returns:all our Shape nodes
Note:you could use getChildren with a predicate, but this method is more efficient as it uses dagpath functions to filter shapes
supports(interface_type)
Returns:True if this instance supports the interface of the given type
Parameter:interface_type – Type of the interface you require this instance to support
Note:Must be used in case you only have a weak reference of your interface instance or proxy which is a case where the ordinary isinstance( obj, iInterface ) will not work
transform()
Returns:Node to lowest transform in the path attached to our node
Note:for shapes this is the parent, for transforms the transform itself
unparent(*args, **kwargs)
As reparent, but will unparent this transform under the scene root

Epydoc: mrv.maya.nt.geometry.DeformableShape

class mrv.maya.nt.geometry.DeformableShape

Bases: mrv.maya.nt.GeometryShape

addAttribute(attr)

Add the given attribute to the node as local dynamic attribute

Parameter:attr – MObject of attribute or Attribute instance as retrieved from a plug
Returns:plug to the newly added attribute
Note:This method is explicitly not undoable as attributes are being deleted in memory right in the moment they are being removed, thus they cannot reside on the undo queue
addChild(*args, **kwargs)

Add the given childNode as child to this Node. Allows instancing !

Parameters:
  • childNode – Node you wish to add
  • position – the index to which to add the new child, kNextPos will add it as last child. It supports python style negative indices
  • keepExistingParent – if True, the childNode will be instanced as it will have its previous parent(s) and this one, if False, the previous parent will be removed from the child’s parent list
  • renameOnClash – resolve nameclashes by automatically renaming the node to make it unique
  • keepWorldSpace – see reparent, only effective if the node is not instanced
Returns:

childNode whose path is pointing to the new child location

Raises ValueError:
 

if keepWorldSpace is requested with directly instanced nodes

Note:

as maya internally handles add/remove child as instancing operation, even though keepExistingParent is False, it will mess up things and for a short period of time in fact have two n + 1 instances, right before one is unlinked, This still fills a slot or something, and isInstanced will be true, although the pathcount is 1. Long story short: if the item to be added to us is not instanced, we use reparent instead. It will not harm in direct instances, so its save to use.

Note:

if the instance count of the item is 1 and keepExistingParent is False, the position argument is being ignored

addInstancedChild(*args, **kwargs)

Add childnode as instanced child to this node

Note:for more information, see addChild
Note:its a shortcut to addChild allowing to clearly indicate what is happening
addParent(*args, **kwargs)

Adds ourselves as instance to the given parentnode at position

Parameter:kwargs – see addChild
Returns:self with updated dag path
classmethod addSep(item, sep)
Returns:

item with separator added to it ( just once )

Note:

operates best on strings

Parameters:
  • item – item to add separator to
  • sep – the separator
addTo(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5c828e0> >, **kwargs)

Add ourselves to the given set

Note:method is undoable
See:sets.ObjectSet
allocateFlag()
apiObject()
Returns:our dag path as this is our api object - the object defining this node best
apiType()
Returns:the MFn Type id of the wrapped object
basename()
Returns:basename of this path, ‘/hello/world’ -> ‘world’
child(index)
Returns:child of self at index
Note:this method fixes the MFnDagNode.child method - it returns an MObject, which doesnt work well with instanced nodes - a dag path is required, which is what we use to aquire the object
childTransforms(predicate=<function <lambda> at 0x5e9b2a8>)
Returns:list of all transform nodes below this one
children(predicate=<function <lambda> at 0x5e99f50>, asNode=True)
Returns:all child nodes below this dag node if predicate returns True for passed Node
Parameter:asNode – if True, you will receive the children as wrapped Nodes, otherwise you get MDagPaths
childrenByType(nodeType, predicate=<function <lambda> at 0x5e9b0c8>)
Returns:all childnodes below this one matching the given nodeType and the predicate
Parameter:nodeType – class of the nodeTyoe, like nt.Transform
childrenDeep(order=1, predicate=<function <lambda> at 0x7f41dd7c5050>)
Returns:

list of all children of path, [ child1 , child2 ]

Parameters:
  • order – order enumeration
  • predicate – returns true if x may be returned
Note:

the child objects returned are supposed to be valid paths, not just relative paths

className()
classification()
componentAssignments(setFilter=(319, False, 0), use_api=True, asComponent=True)
Returns:

list of tuples(ObjectSetNode, Component_or_MObject) defininmg shader assignments on per component basis.

If a shader is assigned to the whole object, the component would be a null object, otherwise it is an instance of a wrapped IndexedComponent class

Note:

The returned Component will be an MObject(kNullObject) only in case the component is not set. Hence you should check whether it isNull() before actually using it.

Parameters:
  • setFilter – see connectedSets
  • use_api – if True, api methods will be used if possible which is usually faster. If False, a custom non-api implementation will be used instead. This can be required if the apiImplementation is not reliable which happens in few cases of ‘weird’ component assignments
  • asComponent – If True, the components will be wrapped into the matching MRV compontent type to provide a nicer interface. This might slightly slow down the process, but this is usually neglectable.
Note:

the sets order will be the order of connections of the respective component list attributes at instObjGroups.objectGroups

Note:

currently only meshes and subdees support per component assignment, whereas only meshes can have per component shader assignments

Note:

SubDivision Components cannot be supported as the component type kSubdivCVComponent cannot be wrapped into any component function set - reevaluate that with new maya versions !

Note:

deformer set component assignments are only returned for instance 0 ! They apply to all output meshes though

connectedSets(setFilter=(459, False, 0))
Returns:list of object set compatible Nodes having self as member
Parameter:setFilter – tuple(apiType, use_exact_type) - the combination of the desired api type and the exact type flag allow precise control whether you which to get only renderable shading engines, only objectfSets (tuple[1] = True), or all objects supporting the given object type. Its preset to only return shading engines
Note:the returned sets order is defined by the order connections to instObjGroups
Note:only sets will be returned that have the whole object as member, thus you will not see sets having component assignments like per-compoent shader assignments or deformer sets
connections()
Returns:MPlugArray of connected plugs
copyFrom(other, *args, **kwargs)

Copy the data from other into self as good as possible Only copy the data that is unique to your specific class - the data of other classes will be taken care of by them !

Note:you must support args and kwargs if one of your iDuplicate bases does

Copy lightlinks from one meshShape to another

Parameter:kwargs
  • substitute:
    if True, default False, the other shape will be put in place of self, effectively receiving it’s light-links whereas self losses them. This is practical in case you create a new shape below a transform that had a previously visible and manipulated shape whose external connections you wouuld like to keep
copyTo(instance, *args, **kwargs)

Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance

Returns:altered instance
Note:instance will be altered during the process
copyToOther(instance, *args, **kwargs)
As copyTo, but does only require the objects to have a common base. It will match the actually compatible base classes and call copyFrom if possible. As more checking is performed, this method performs worse than copyTo
createInstance(*args, **kwargs)

Create and Initialize an instance of self.__class__( ... ) based on your own data

Returns:new instance of self
Note:using self.__class__ instead of an explicit class allows derived classes that do not have anything to duplicate just to use your implementeation
Note:you must support args and kwargs if one of your iDuplicate bases does
dagPath()
Returns:the original DagPath attached to this Node - it’s not wrapped for performance
Note:If you plan to alter it, make sure you copy it using the MDagPath(node.dagPath()) construct !
deallocateAllFlags()
deallocateFlag()
delete(*args, **kwargs)

Delete this node - this special version must be

Note:if the undo queue is enabled, the object becomes invalid, but stays alive until it drops off the queue
Note:if you want to delete many nodes, its more efficient to delete them using the global delete method
dependencyInfo(attribute, by=True)
Returns:

list of attributes that given attribute affects or that the given attribute is affected by if the attribute turns dirty.

Parameters:
  • attribute – attribute instance or attribute name
  • by – if false, affected attributes will be returned, otherwise the attributes affecting this one
Note:

see also MPlug.affectedByPlugs

Note:

USING MEL: as api command and mObject array always crashed on me ... don’t know :(

displayOverrideValue(plugName)
Returns:the override display value actually identified by plugName affecting the given object (that should be a leaf node for the result you see in the viewport. The display type in effect is always the last one set in the hierarchy returns None display overrides are disabled
duplicate(*args, **kwargs)

Duplciate the given node to newpath

Parameters:
  • newpath

    result depends on its format:

    • ‘’ - empty string, creates a unique name based on the actual node name by appending a copy number to it, if newTransform is True, the newly created shape/transform will keep its name, but receives a new parent
    • ‘newname’ - relative path, the node will be duplicated not changing its current parent if newTransform is False
    • |parent|newname - absolute path, the node will be duplicated and reparented under the given path
      if newTransform is True, a new transform name will be created based on your name by appending a unique copy number
  • autocreateNamespace – if true, namespaces given in newpath will be created automatically, otherwise a RuntimeException will be thrown if a required namespace does not exist
  • renameOnClash – if true, clashing names will automatically be resolved by adjusting the name
  • newTransform – if True, a new transform will be created based on the name of the parent transform of this shape node, appending a unique copy number to it. Only has an effect for shape nodes
Returns:

newly create Node

Note:

duplicate performance could be improved by checking more before doing work that does not really change the scene, but adds undo operations

Note:

inbetween parents are always required as needed

Todo:

add example for each version of newpath

Note:

instancing can be realized using the addChild function

Note:

If meshes have tweaks applied, the duplicate will not have these tweaks and the meshes will look mislocated. Using MEL works in that case ... (they fixed it there obviously) , but creates invalid objects

Todo:

Undo implementation - every undoable operation must in fact be based on strings to really work, all this is far too much - dagNode.duplicate must be undoable by itself

Todo:

duplicate should be completely reimplemented to support all mel options and actually work with meshes and tweaks - the underlying api duplication would still be used of course, as well as connections (to sets) and so on ...

fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
classmethod getMFnClasses()
Returns:list of all function set classes this node supports, most derived function set comes first
hasChild(node)
Returns:True if node is a child of self
hasFn(mfntype)
Returns:True if our object supports the given function set type
instance(instanceNumber)
Returns:Node to the instance identified by instanceNumber
Parameter:instanceNumber – range(0, self.instanceCount()-1)
instanceNumber()
Returns:our instance number
Note:0 does not indicate that this object is not instanced - use getInstanceCount instead
isAlive()
Returns:True if the object exists in memory
Note:objects on the undo queue are alive, but NOT valid
isMemberOf(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5c1d740> >)
Returns:True if self is part of setnode
Note:method is undoable
See:sets.ObjectSet
isPartOf(other)
Returns:True if self is a part of other, and thus can be found in other
Note:operates on strings only
isRoot()
Returns:True if this path is the root of the DAG
isRootOf(other)
Returns:True other starts with self
Note:operates on strings
Note:we assume other has the same type as self, thus the same separator
isTemplate()
Returns:True if this node is templated - this is the case if itself or one of its parents are templated
isValid()
Returns:True if the object exists in the scene
Note:Handles DAG objects correctly that can be instanced, in which case the MObject may be valid , but the respective dag path is not. Additionally, if the object is not parented below any object, everything appears to be valid, but the path name is empty
isVisible()
Returns:True if this node is visible - its visible if itself and all parents are visible
iterInstances(excludeSelf=False)

Get iterator over all (direct and indirect)instances of this node

Parameter:excludeSelf – if True, self will not be returned, if False, it will be in the list of items
Note:Iterating instances is more efficient than querying all instances individually using instance
Todo:add flag to allow iteration of indirect instances as well
iterParents(predicate=<function <lambda> at 0x7f41dd7c5230>)
Returns:generator retrieving all parents up to the root
Parameter:predicate – returns True for all x that you want to be returned
name()
Returns:fully qualified (long) name of this dag node
object()
Returns:MObject as retrieved from the MDagPath of our Node
parent()
Returns:Maya node of the parent of this instance or None if this is the root
parentAtIndex(index)
Returns:Node of the parent at the given index - non-instanced nodes only have one parent
Note:if a node is instanced, it can have parentCount parents
Todo:Update dagpath afterwards ! Use dagpaths instead !
parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
referenceFile()
Returns:name (str) of file this node is coming from - it could contain a copy number as {x}
Note:will raise if the node is not referenced, use isReferenced to figure that out
removeAttribute(attr)

Remove the given attribute from the node

Parameter:attr – see addAttribute
removeChild(*args, **kwargs)

remove the given childNode (being a child of this node) from our child list, effectively parenting it under world !

Parameters:
  • childNode – Node to unparent - if it is not one of our children, no change takes place
  • allowZeroParents – if True, it is possible to leave a node unparented, thus no valid dag paths leads to it. If False, transforms will just be reparented under the world
Returns:

copy of childnode pointing to the first valid dag path we find.

Note:

to prevent the child (if transform) to dangle in unknown space if the last instance is to be removed, it will instead be reparented to world.

Note:

removing shapes from their last parent will result in an error

removeFrom(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5b41420> >)

remove ourselves to the given set

Note:method is undoable
See:sets.ObjectSet
removeParent(*args, **kwargs)

Remove ourselves from given parentnode

Returns:None
rename(*args, **kwargs)

Rename this node to newname

Parameters:
  • newname – new name of the node
  • autocreateNamespace – if true, namespaces given in newpath will be created automatically, otherwise a RuntimeException will be thrown if a required namespace does not exist
  • renameOnClash – if true, clashing names will automatically be resolved by adjusting the name
Returns:

renamed node which is the node itself

Note:

for safety reasons, this node is dagnode aware and uses a dag modifier for them !

reparent(*args, **kwargs)

Change the parent of all nodes (also instances) to be located below parentnode

Parameters:
  • parentnode – Node instance of transform under which this node should be parented to if None, node will be reparented under the root (which only works for transforms)
  • renameOnClash – resolve nameclashes by automatically renaming the node to make it unique
  • raiseOnInstance – if True, this method will raise if you try to reparent an instanced object. If false, instanced objects will be merged into the newly created path under parentnode, effectively eliminating all other paths , keeping the newly created one
  • keepWorldSpace – if True and node to be reparented is a transform, the world space position will be kept by adjusting the transformation accordingly. WARNNG: Currently we reset pivots when doing so

:return : copy of self pointing to the new dag path self

Note:will remove all instance of this object and leave this object at only one path - if this is not what you want, use the addChild method instead as it can properly handle this case
Note:this method handles namespaces properly
root()
Returns:the root of the DAG - it has no further parents
setLocked(*args, **kwargs)

Lock or unloack this node

Parameter:state – if True, the node is locked. Locked nodes cannot be deleted, renamed or reparented
Note:you can query the lock state with isLocked
setNamespace(*args, **kwargs)
Returns:

self after being moved to the given namespace. This will effectively rename the object.

Parameters:
  • newns – Namespace instance to put this Node into
  • kwargs – to be passed to rename
setParent(*args, **kwargs)

Change the parent of self to parentnode being placed at position

Parameter:kwargs – see addChild
Returns:self with updated dag path
sets(setFilter=(459, False, 0))
Returns:list of object set compatible Nodes having self as member
Parameter:setFilter – tuple(apiType, use_exact_type) - the combination of the desired api type and the exact type flag allow precise control whether you which to get only renderable shading engines, only objectfSets (tuple[1] = True), or all objects supporting the given object type. Its preset to only return shading engines
Note:the returned sets order is defined by the order connections to instObjGroups
Note:only sets will be returned that have the whole object as member, thus you will not see sets having component assignments like per-compoent shader assignments or deformer sets
shapes(predicate=<function <lambda> at 0x5e9b1b8>)
Returns:all our Shape nodes
Note:you could use getChildren with a predicate, but this method is more efficient as it uses dagpath functions to filter shapes
supports(interface_type)
Returns:True if this instance supports the interface of the given type
Parameter:interface_type – Type of the interface you require this instance to support
Note:Must be used in case you only have a weak reference of your interface instance or proxy which is a case where the ordinary isinstance( obj, iInterface ) will not work
transform()
Returns:Node to lowest transform in the path attached to our node
Note:for shapes this is the parent, for transforms the transform itself
unparent(*args, **kwargs)
As reparent, but will unparent this transform under the scene root

Epydoc: mrv.maya.nt.geometry.GeometryShape

class mrv.maya.nt.geometry.GeometryShape

Bases: mrv.maya.nt.Shape

Contains common methods for all geometry types

addAttribute(attr)

Add the given attribute to the node as local dynamic attribute

Parameter:attr – MObject of attribute or Attribute instance as retrieved from a plug
Returns:plug to the newly added attribute
Note:This method is explicitly not undoable as attributes are being deleted in memory right in the moment they are being removed, thus they cannot reside on the undo queue
addChild(*args, **kwargs)

Add the given childNode as child to this Node. Allows instancing !

Parameters:
  • childNode – Node you wish to add
  • position – the index to which to add the new child, kNextPos will add it as last child. It supports python style negative indices
  • keepExistingParent – if True, the childNode will be instanced as it will have its previous parent(s) and this one, if False, the previous parent will be removed from the child’s parent list
  • renameOnClash – resolve nameclashes by automatically renaming the node to make it unique
  • keepWorldSpace – see reparent, only effective if the node is not instanced
Returns:

childNode whose path is pointing to the new child location

Raises ValueError:
 

if keepWorldSpace is requested with directly instanced nodes

Note:

as maya internally handles add/remove child as instancing operation, even though keepExistingParent is False, it will mess up things and for a short period of time in fact have two n + 1 instances, right before one is unlinked, This still fills a slot or something, and isInstanced will be true, although the pathcount is 1. Long story short: if the item to be added to us is not instanced, we use reparent instead. It will not harm in direct instances, so its save to use.

Note:

if the instance count of the item is 1 and keepExistingParent is False, the position argument is being ignored

addInstancedChild(*args, **kwargs)

Add childnode as instanced child to this node

Note:for more information, see addChild
Note:its a shortcut to addChild allowing to clearly indicate what is happening
addParent(*args, **kwargs)

Adds ourselves as instance to the given parentnode at position

Parameter:kwargs – see addChild
Returns:self with updated dag path
classmethod addSep(item, sep)
Returns:

item with separator added to it ( just once )

Note:

operates best on strings

Parameters:
  • item – item to add separator to
  • sep – the separator
addTo(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5c828e0> >, **kwargs)

Add ourselves to the given set

Note:method is undoable
See:sets.ObjectSet
allocateFlag()
apiObject()
Returns:our dag path as this is our api object - the object defining this node best
apiType()
Returns:the MFn Type id of the wrapped object
basename()
Returns:basename of this path, ‘/hello/world’ -> ‘world’
child(index)
Returns:child of self at index
Note:this method fixes the MFnDagNode.child method - it returns an MObject, which doesnt work well with instanced nodes - a dag path is required, which is what we use to aquire the object
childTransforms(predicate=<function <lambda> at 0x5e9b2a8>)
Returns:list of all transform nodes below this one
children(predicate=<function <lambda> at 0x5e99f50>, asNode=True)
Returns:all child nodes below this dag node if predicate returns True for passed Node
Parameter:asNode – if True, you will receive the children as wrapped Nodes, otherwise you get MDagPaths
childrenByType(nodeType, predicate=<function <lambda> at 0x5e9b0c8>)
Returns:all childnodes below this one matching the given nodeType and the predicate
Parameter:nodeType – class of the nodeTyoe, like nt.Transform
childrenDeep(order=1, predicate=<function <lambda> at 0x7f41dd7c5050>)
Returns:

list of all children of path, [ child1 , child2 ]

Parameters:
  • order – order enumeration
  • predicate – returns true if x may be returned
Note:

the child objects returned are supposed to be valid paths, not just relative paths

className()
classification()
componentAssignments(setFilter=(319, False, 0), use_api=True, asComponent=True)
Returns:

list of tuples(ObjectSetNode, Component_or_MObject) defininmg shader assignments on per component basis.

If a shader is assigned to the whole object, the component would be a null object, otherwise it is an instance of a wrapped IndexedComponent class

Note:

The returned Component will be an MObject(kNullObject) only in case the component is not set. Hence you should check whether it isNull() before actually using it.

Parameters:
  • setFilter – see connectedSets
  • use_api – if True, api methods will be used if possible which is usually faster. If False, a custom non-api implementation will be used instead. This can be required if the apiImplementation is not reliable which happens in few cases of ‘weird’ component assignments
  • asComponent – If True, the components will be wrapped into the matching MRV compontent type to provide a nicer interface. This might slightly slow down the process, but this is usually neglectable.
Note:

the sets order will be the order of connections of the respective component list attributes at instObjGroups.objectGroups

Note:

currently only meshes and subdees support per component assignment, whereas only meshes can have per component shader assignments

Note:

SubDivision Components cannot be supported as the component type kSubdivCVComponent cannot be wrapped into any component function set - reevaluate that with new maya versions !

Note:

deformer set component assignments are only returned for instance 0 ! They apply to all output meshes though

connectedSets(setFilter=(459, False, 0))
Returns:list of object set compatible Nodes having self as member
Parameter:setFilter – tuple(apiType, use_exact_type) - the combination of the desired api type and the exact type flag allow precise control whether you which to get only renderable shading engines, only objectfSets (tuple[1] = True), or all objects supporting the given object type. Its preset to only return shading engines
Note:the returned sets order is defined by the order connections to instObjGroups
Note:only sets will be returned that have the whole object as member, thus you will not see sets having component assignments like per-compoent shader assignments or deformer sets
connections()
Returns:MPlugArray of connected plugs
copyFrom(other, *args, **kwargs)

Copy the data from other into self as good as possible Only copy the data that is unique to your specific class - the data of other classes will be taken care of by them !

Note:you must support args and kwargs if one of your iDuplicate bases does

Copy lightlinks from one meshShape to another

Parameter:kwargs
  • substitute:
    if True, default False, the other shape will be put in place of self, effectively receiving it’s light-links whereas self losses them. This is practical in case you create a new shape below a transform that had a previously visible and manipulated shape whose external connections you wouuld like to keep
copyTo(instance, *args, **kwargs)

Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance

Returns:altered instance
Note:instance will be altered during the process
copyToOther(instance, *args, **kwargs)
As copyTo, but does only require the objects to have a common base. It will match the actually compatible base classes and call copyFrom if possible. As more checking is performed, this method performs worse than copyTo
createInstance(*args, **kwargs)

Create and Initialize an instance of self.__class__( ... ) based on your own data

Returns:new instance of self
Note:using self.__class__ instead of an explicit class allows derived classes that do not have anything to duplicate just to use your implementeation
Note:you must support args and kwargs if one of your iDuplicate bases does
dagPath()
Returns:the original DagPath attached to this Node - it’s not wrapped for performance
Note:If you plan to alter it, make sure you copy it using the MDagPath(node.dagPath()) construct !
deallocateAllFlags()
deallocateFlag()
delete(*args, **kwargs)

Delete this node - this special version must be

Note:if the undo queue is enabled, the object becomes invalid, but stays alive until it drops off the queue
Note:if you want to delete many nodes, its more efficient to delete them using the global delete method
dependencyInfo(attribute, by=True)
Returns:

list of attributes that given attribute affects or that the given attribute is affected by if the attribute turns dirty.

Parameters:
  • attribute – attribute instance or attribute name
  • by – if false, affected attributes will be returned, otherwise the attributes affecting this one
Note:

see also MPlug.affectedByPlugs

Note:

USING MEL: as api command and mObject array always crashed on me ... don’t know :(

displayOverrideValue(plugName)
Returns:the override display value actually identified by plugName affecting the given object (that should be a leaf node for the result you see in the viewport. The display type in effect is always the last one set in the hierarchy returns None display overrides are disabled
duplicate(*args, **kwargs)

Duplciate the given node to newpath

Parameters:
  • newpath

    result depends on its format:

    • ‘’ - empty string, creates a unique name based on the actual node name by appending a copy number to it, if newTransform is True, the newly created shape/transform will keep its name, but receives a new parent
    • ‘newname’ - relative path, the node will be duplicated not changing its current parent if newTransform is False
    • |parent|newname - absolute path, the node will be duplicated and reparented under the given path
      if newTransform is True, a new transform name will be created based on your name by appending a unique copy number
  • autocreateNamespace – if true, namespaces given in newpath will be created automatically, otherwise a RuntimeException will be thrown if a required namespace does not exist
  • renameOnClash – if true, clashing names will automatically be resolved by adjusting the name
  • newTransform – if True, a new transform will be created based on the name of the parent transform of this shape node, appending a unique copy number to it. Only has an effect for shape nodes
Returns:

newly create Node

Note:

duplicate performance could be improved by checking more before doing work that does not really change the scene, but adds undo operations

Note:

inbetween parents are always required as needed

Todo:

add example for each version of newpath

Note:

instancing can be realized using the addChild function

Note:

If meshes have tweaks applied, the duplicate will not have these tweaks and the meshes will look mislocated. Using MEL works in that case ... (they fixed it there obviously) , but creates invalid objects

Todo:

Undo implementation - every undoable operation must in fact be based on strings to really work, all this is far too much - dagNode.duplicate must be undoable by itself

Todo:

duplicate should be completely reimplemented to support all mel options and actually work with meshes and tweaks - the underlying api duplication would still be used of course, as well as connections (to sets) and so on ...

fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
classmethod getMFnClasses()
Returns:list of all function set classes this node supports, most derived function set comes first
hasChild(node)
Returns:True if node is a child of self
hasFn(mfntype)
Returns:True if our object supports the given function set type
instance(instanceNumber)
Returns:Node to the instance identified by instanceNumber
Parameter:instanceNumber – range(0, self.instanceCount()-1)
instanceNumber()
Returns:our instance number
Note:0 does not indicate that this object is not instanced - use getInstanceCount instead
isAlive()
Returns:True if the object exists in memory
Note:objects on the undo queue are alive, but NOT valid
isMemberOf(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5c1d740> >)
Returns:True if self is part of setnode
Note:method is undoable
See:sets.ObjectSet
isPartOf(other)
Returns:True if self is a part of other, and thus can be found in other
Note:operates on strings only
isRoot()
Returns:True if this path is the root of the DAG
isRootOf(other)
Returns:True other starts with self
Note:operates on strings
Note:we assume other has the same type as self, thus the same separator
isTemplate()
Returns:True if this node is templated - this is the case if itself or one of its parents are templated
isValid()
Returns:True if the object exists in the scene
Note:Handles DAG objects correctly that can be instanced, in which case the MObject may be valid , but the respective dag path is not. Additionally, if the object is not parented below any object, everything appears to be valid, but the path name is empty
isVisible()
Returns:True if this node is visible - its visible if itself and all parents are visible
iterInstances(excludeSelf=False)

Get iterator over all (direct and indirect)instances of this node

Parameter:excludeSelf – if True, self will not be returned, if False, it will be in the list of items
Note:Iterating instances is more efficient than querying all instances individually using instance
Todo:add flag to allow iteration of indirect instances as well
iterParents(predicate=<function <lambda> at 0x7f41dd7c5230>)
Returns:generator retrieving all parents up to the root
Parameter:predicate – returns True for all x that you want to be returned
name()
Returns:fully qualified (long) name of this dag node
object()
Returns:MObject as retrieved from the MDagPath of our Node
parent()
Returns:Maya node of the parent of this instance or None if this is the root
parentAtIndex(index)
Returns:Node of the parent at the given index - non-instanced nodes only have one parent
Note:if a node is instanced, it can have parentCount parents
Todo:Update dagpath afterwards ! Use dagpaths instead !
parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
referenceFile()
Returns:name (str) of file this node is coming from - it could contain a copy number as {x}
Note:will raise if the node is not referenced, use isReferenced to figure that out
removeAttribute(attr)

Remove the given attribute from the node

Parameter:attr – see addAttribute
removeChild(*args, **kwargs)

remove the given childNode (being a child of this node) from our child list, effectively parenting it under world !

Parameters:
  • childNode – Node to unparent - if it is not one of our children, no change takes place
  • allowZeroParents – if True, it is possible to leave a node unparented, thus no valid dag paths leads to it. If False, transforms will just be reparented under the world
Returns:

copy of childnode pointing to the first valid dag path we find.

Note:

to prevent the child (if transform) to dangle in unknown space if the last instance is to be removed, it will instead be reparented to world.

Note:

removing shapes from their last parent will result in an error

removeFrom(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5b41420> >)

remove ourselves to the given set

Note:method is undoable
See:sets.ObjectSet
removeParent(*args, **kwargs)

Remove ourselves from given parentnode

Returns:None
rename(*args, **kwargs)

Rename this node to newname

Parameters:
  • newname – new name of the node
  • autocreateNamespace – if true, namespaces given in newpath will be created automatically, otherwise a RuntimeException will be thrown if a required namespace does not exist
  • renameOnClash – if true, clashing names will automatically be resolved by adjusting the name
Returns:

renamed node which is the node itself

Note:

for safety reasons, this node is dagnode aware and uses a dag modifier for them !

reparent(*args, **kwargs)

Change the parent of all nodes (also instances) to be located below parentnode

Parameters:
  • parentnode – Node instance of transform under which this node should be parented to if None, node will be reparented under the root (which only works for transforms)
  • renameOnClash – resolve nameclashes by automatically renaming the node to make it unique
  • raiseOnInstance – if True, this method will raise if you try to reparent an instanced object. If false, instanced objects will be merged into the newly created path under parentnode, effectively eliminating all other paths , keeping the newly created one
  • keepWorldSpace – if True and node to be reparented is a transform, the world space position will be kept by adjusting the transformation accordingly. WARNNG: Currently we reset pivots when doing so

:return : copy of self pointing to the new dag path self

Note:will remove all instance of this object and leave this object at only one path - if this is not what you want, use the addChild method instead as it can properly handle this case
Note:this method handles namespaces properly
root()
Returns:the root of the DAG - it has no further parents
setLocked(*args, **kwargs)

Lock or unloack this node

Parameter:state – if True, the node is locked. Locked nodes cannot be deleted, renamed or reparented
Note:you can query the lock state with isLocked
setNamespace(*args, **kwargs)
Returns:

self after being moved to the given namespace. This will effectively rename the object.

Parameters:
  • newns – Namespace instance to put this Node into
  • kwargs – to be passed to rename
setParent(*args, **kwargs)

Change the parent of self to parentnode being placed at position

Parameter:kwargs – see addChild
Returns:self with updated dag path
sets(setFilter=(459, False, 0))
Returns:list of object set compatible Nodes having self as member
Parameter:setFilter – tuple(apiType, use_exact_type) - the combination of the desired api type and the exact type flag allow precise control whether you which to get only renderable shading engines, only objectfSets (tuple[1] = True), or all objects supporting the given object type. Its preset to only return shading engines
Note:the returned sets order is defined by the order connections to instObjGroups
Note:only sets will be returned that have the whole object as member, thus you will not see sets having component assignments like per-compoent shader assignments or deformer sets
shapes(predicate=<function <lambda> at 0x5e9b1b8>)
Returns:all our Shape nodes
Note:you could use getChildren with a predicate, but this method is more efficient as it uses dagpath functions to filter shapes
supports(interface_type)
Returns:True if this instance supports the interface of the given type
Parameter:interface_type – Type of the interface you require this instance to support
Note:Must be used in case you only have a weak reference of your interface instance or proxy which is a case where the ordinary isinstance( obj, iInterface ) will not work
transform()
Returns:Node to lowest transform in the path attached to our node
Note:for shapes this is the parent, for transforms the transform itself
unparent(*args, **kwargs)
As reparent, but will unparent this transform under the scene root

Epydoc: mrv.maya.nt.geometry.Mesh

class mrv.maya.nt.geometry.Mesh

Bases: mrv.maya.nt.SurfaceShape

Implemnetation of mesh related methods to make its handling more convenient

Component Access:

>>> m.cvtx[:]                   # a complete set of components
>>> m.cvtx[1:4]                 # initialized with 3 indices
>>> m.cvtx[1]                   # initialized with a single index
>>> m.cvtx[1,2,3]               # initialized with multiple indices
>>> m.cf[(1,2,3)]               # initialized with list or tuple
>>> m.ce[iter(1,2,3)]           # initialized from iterator
>>> m.ce[api.MIntArray()]       # initialized from MIntArray
addAttribute(attr)

Add the given attribute to the node as local dynamic attribute

Parameter:attr – MObject of attribute or Attribute instance as retrieved from a plug
Returns:plug to the newly added attribute
Note:This method is explicitly not undoable as attributes are being deleted in memory right in the moment they are being removed, thus they cannot reside on the undo queue
addChild(*args, **kwargs)

Add the given childNode as child to this Node. Allows instancing !

Parameters:
  • childNode – Node you wish to add
  • position – the index to which to add the new child, kNextPos will add it as last child. It supports python style negative indices
  • keepExistingParent – if True, the childNode will be instanced as it will have its previous parent(s) and this one, if False, the previous parent will be removed from the child’s parent list
  • renameOnClash – resolve nameclashes by automatically renaming the node to make it unique
  • keepWorldSpace – see reparent, only effective if the node is not instanced
Returns:

childNode whose path is pointing to the new child location

Raises ValueError:
 

if keepWorldSpace is requested with directly instanced nodes

Note:

as maya internally handles add/remove child as instancing operation, even though keepExistingParent is False, it will mess up things and for a short period of time in fact have two n + 1 instances, right before one is unlinked, This still fills a slot or something, and isInstanced will be true, although the pathcount is 1. Long story short: if the item to be added to us is not instanced, we use reparent instead. It will not harm in direct instances, so its save to use.

Note:

if the instance count of the item is 1 and keepExistingParent is False, the position argument is being ignored

addInstancedChild(*args, **kwargs)

Add childnode as instanced child to this node

Note:for more information, see addChild
Note:its a shortcut to addChild allowing to clearly indicate what is happening
addParent(*args, **kwargs)

Adds ourselves as instance to the given parentnode at position

Parameter:kwargs – see addChild
Returns:self with updated dag path
classmethod addSep(item, sep)
Returns:

item with separator added to it ( just once )

Note:

operates best on strings

Parameters:
  • item – item to add separator to
  • sep – the separator
addTo(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5c828e0> >, **kwargs)

Add ourselves to the given set

Note:method is undoable
See:sets.ObjectSet
allocateFlag()
apiObject()
Returns:our dag path as this is our api object - the object defining this node best
apiType()
Returns:the MFn Type id of the wrapped object
autoUniformGridParams()
basename()
Returns:basename of this path, ‘/hello/world’ -> ‘world’
ce
cf
child(index)
Returns:child of self at index
Note:this method fixes the MFnDagNode.child method - it returns an MObject, which doesnt work well with instanced nodes - a dag path is required, which is what we use to aquire the object
childTransforms(predicate=<function <lambda> at 0x5e9b2a8>)
Returns:list of all transform nodes below this one
children(predicate=<function <lambda> at 0x5e99f50>, asNode=True)
Returns:all child nodes below this dag node if predicate returns True for passed Node
Parameter:asNode – if True, you will receive the children as wrapped Nodes, otherwise you get MDagPaths
childrenByType(nodeType, predicate=<function <lambda> at 0x5e9b0c8>)
Returns:all childnodes below this one matching the given nodeType and the predicate
Parameter:nodeType – class of the nodeTyoe, like nt.Transform
childrenDeep(order=1, predicate=<function <lambda> at 0x7f41dd7c5050>)
Returns:

list of all children of path, [ child1 , child2 ]

Parameters:
  • order – order enumeration
  • predicate – returns true if x may be returned
Note:

the child objects returned are supposed to be valid paths, not just relative paths

className()
classification()
clearGlobalIntersectionAcceleratorInfo()
cmap
component(component_type)
Returns:A component object able to hold the given component type
Parameter:component_type – a member of the eComponentType enumeration
componentAssignments(setFilter=(319, False, 0), use_api=True, asComponent=True)
Returns:

list of tuples(ObjectSetNode, Component_or_MObject) defininmg shader assignments on per component basis.

If a shader is assigned to the whole object, the component would be a null object, otherwise it is an instance of a wrapped IndexedComponent class

Note:

The returned Component will be an MObject(kNullObject) only in case the component is not set. Hence you should check whether it isNull() before actually using it.

Parameters:
  • setFilter – see connectedSets
  • use_api – if True, api methods will be used if possible which is usually faster. If False, a custom non-api implementation will be used instead. This can be required if the apiImplementation is not reliable which happens in few cases of ‘weird’ component assignments
  • asComponent – If True, the components will be wrapped into the matching MRV compontent type to provide a nicer interface. This might slightly slow down the process, but this is usually neglectable.
Note:

the sets order will be the order of connections of the respective component list attributes at instObjGroups.objectGroups

Note:

currently only meshes and subdees support per component assignment, whereas only meshes can have per component shader assignments

Note:

SubDivision Components cannot be supported as the component type kSubdivCVComponent cannot be wrapped into any component function set - reevaluate that with new maya versions !

Note:

deformer set component assignments are only returned for instance 0 ! They apply to all output meshes though

connectedSets(setFilter=(459, False, 0))
Returns:list of object set compatible Nodes having self as member
Parameter:setFilter – tuple(apiType, use_exact_type) - the combination of the desired api type and the exact type flag allow precise control whether you which to get only renderable shading engines, only objectfSets (tuple[1] = True), or all objects supporting the given object type. Its preset to only return shading engines
Note:the returned sets order is defined by the order connections to instObjGroups
Note:only sets will be returned that have the whole object as member, thus you will not see sets having component assignments like per-compoent shader assignments or deformer sets
connections()
Returns:MPlugArray of connected plugs
copyAssignmentsTo(*args, **kwargs)

Copy set assignments including component assignments to other

Parameter:kwargs – passed to set.addMember, additional kwargs are: * setFilter: default is fSetsRenderable
copyFrom(other, *args, **kwargs)

Copy tweaks and sets from other onto self

Parameter:kwargs
  • setFilter: if given, default is fSets, you may specify the types of sets to copy
    if None, no set conenctions will be copied

Copy lightlinks from one meshShape to another

Parameter:kwargs
  • substitute:
    if True, default False, the other shape will be put in place of self, effectively receiving it’s light-links whereas self losses them. This is practical in case you create a new shape below a transform that had a previously visible and manipulated shape whose external connections you wouuld like to keep
copyTo(instance, *args, **kwargs)

Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance

Returns:altered instance
Note:instance will be altered during the process
copyToOther(instance, *args, **kwargs)
As copyTo, but does only require the objects to have a common base. It will match the actually compatible base classes and call copyFrom if possible. As more checking is performed, this method performs worse than copyTo
copyTweaksTo(other)

Copy our tweaks onto another mesh

Note:we do not check topology for maximum flexibility
createInstance(*args, **kwargs)

Create and Initialize an instance of self.__class__( ... ) based on your own data

Returns:new instance of self
Note:using self.__class__ instead of an explicit class allows derived classes that do not have anything to duplicate just to use your implementeation
Note:you must support args and kwargs if one of your iDuplicate bases does
cvtx
dagPath()
Returns:the original DagPath attached to this Node - it’s not wrapped for performance
Note:If you plan to alter it, make sure you copy it using the MDagPath(node.dagPath()) construct !
deallocateAllFlags()
deallocateFlag()
delete(*args, **kwargs)

Delete this node - this special version must be

Note:if the undo queue is enabled, the object becomes invalid, but stays alive until it drops off the queue
Note:if you want to delete many nodes, its more efficient to delete them using the global delete method
dependencyInfo(attribute, by=True)
Returns:

list of attributes that given attribute affects or that the given attribute is affected by if the attribute turns dirty.

Parameters:
  • attribute – attribute instance or attribute name
  • by – if false, affected attributes will be returned, otherwise the attributes affecting this one
Note:

see also MPlug.affectedByPlugs

Note:

USING MEL: as api command and mObject array always crashed on me ... don’t know :(

displayOverrideValue(plugName)
Returns:the override display value actually identified by plugName affecting the given object (that should be a leaf node for the result you see in the viewport. The display type in effect is always the last one set in the hierarchy returns None display overrides are disabled
duplicate(*args, **kwargs)

Duplciate the given node to newpath

Parameters:
  • newpath

    result depends on its format:

    • ‘’ - empty string, creates a unique name based on the actual node name by appending a copy number to it, if newTransform is True, the newly created shape/transform will keep its name, but receives a new parent
    • ‘newname’ - relative path, the node will be duplicated not changing its current parent if newTransform is False
    • |parent|newname - absolute path, the node will be duplicated and reparented under the given path
      if newTransform is True, a new transform name will be created based on your name by appending a unique copy number
  • autocreateNamespace – if true, namespaces given in newpath will be created automatically, otherwise a RuntimeException will be thrown if a required namespace does not exist
  • renameOnClash – if true, clashing names will automatically be resolved by adjusting the name
  • newTransform – if True, a new transform will be created based on the name of the parent transform of this shape node, appending a unique copy number to it. Only has an effect for shape nodes
Returns:

newly create Node

Note:

duplicate performance could be improved by checking more before doing work that does not really change the scene, but adds undo operations

Note:

inbetween parents are always required as needed

Todo:

add example for each version of newpath

Note:

instancing can be realized using the addChild function

Note:

If meshes have tweaks applied, the duplicate will not have these tweaks and the meshes will look mislocated. Using MEL works in that case ... (they fixed it there obviously) , but creates invalid objects

Todo:

Undo implementation - every undoable operation must in fact be based on strings to really work, all this is far too much - dagNode.duplicate must be undoable by itself

Todo:

duplicate should be completely reimplemented to support all mel options and actually work with meshes and tweaks - the underlying api duplication would still be used of course, as well as connections (to sets) and so on ...

e
f
fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
classmethod getMFnClasses()
Returns:list of all function set classes this node supports, most derived function set comes first
globalIntersectionAcceleratorsInfo()
hasChild(node)
Returns:True if node is a child of self
hasFn(mfntype)
Returns:True if our object supports the given function set type
instance(instanceNumber)
Returns:Node to the instance identified by instanceNumber
Parameter:instanceNumber – range(0, self.instanceCount()-1)
instanceNumber()
Returns:our instance number
Note:0 does not indicate that this object is not instanced - use getInstanceCount instead
isAlive()
Returns:True if the object exists in memory
Note:objects on the undo queue are alive, but NOT valid
isMemberOf(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5c1d740> >)
Returns:True if self is part of setnode
Note:method is undoable
See:sets.ObjectSet
isPartOf(other)
Returns:True if self is a part of other, and thus can be found in other
Note:operates on strings only
isRoot()
Returns:True if this path is the root of the DAG
isRootOf(other)
Returns:True other starts with self
Note:operates on strings
Note:we assume other has the same type as self, thus the same separator
isTemplate()
Returns:True if this node is templated - this is the case if itself or one of its parents are templated
isValid()
Returns:True if the object exists in the scene
Note:Handles DAG objects correctly that can be instanced, in which case the MObject may be valid , but the respective dag path is not. Additionally, if the object is not parented below any object, everything appears to be valid, but the path name is empty
isValidMesh()
Returns:True if we are nonempty and valid - emptry meshes do not work with the mfnmesh although it should ! Have to catch that case ourselves
isVisible()
Returns:True if this node is visible - its visible if itself and all parents are visible
iterComponents(component_type, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5e55590> >)
Returns:

MItIterator matching your component_type to iteartor over items on this mesh

Parameters:
  • component_type
    • vertex -> MItMeshVertex
    • edge -> MItMeshEdge
    • face -> MItMeshPolygon
    • uv -> MItMeshFaceVertex
  • component – if not kNullObject, the iterator returned will be constrained to the given indices as described by the Component. Use component to retrieve a matching component type’s instance
iterInstances(excludeSelf=False)

Get iterator over all (direct and indirect)instances of this node

Parameter:excludeSelf – if True, self will not be returned, if False, it will be in the list of items
Note:Iterating instances is more efficient than querying all instances individually using instance
Todo:add flag to allow iteration of indirect instances as well
iterParents(predicate=<function <lambda> at 0x7f41dd7c5230>)
Returns:generator retrieving all parents up to the root
Parameter:predicate – returns True for all x that you want to be returned
map
name()
Returns:fully qualified (long) name of this dag node
object()
Returns:MObject as retrieved from the MDagPath of our Node
parent()
Returns:Maya node of the parent of this instance or None if this is the root
parentAtIndex(index)
Returns:Node of the parent at the given index - non-instanced nodes only have one parent
Note:if a node is instanced, it can have parentCount parents
Todo:Update dagpath afterwards ! Use dagpaths instead !
parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
referenceFile()
Returns:name (str) of file this node is coming from - it could contain a copy number as {x}
Note:will raise if the node is not referenced, use isReferenced to figure that out
removeAttribute(attr)

Remove the given attribute from the node

Parameter:attr – see addAttribute
removeChild(*args, **kwargs)

remove the given childNode (being a child of this node) from our child list, effectively parenting it under world !

Parameters:
  • childNode – Node to unparent - if it is not one of our children, no change takes place
  • allowZeroParents – if True, it is possible to leave a node unparented, thus no valid dag paths leads to it. If False, transforms will just be reparented under the world
Returns:

copy of childnode pointing to the first valid dag path we find.

Note:

to prevent the child (if transform) to dangle in unknown space if the last instance is to be removed, it will instead be reparented to world.

Note:

removing shapes from their last parent will result in an error

removeFrom(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5b41420> >)

remove ourselves to the given set

Note:method is undoable
See:sets.ObjectSet
removeParent(*args, **kwargs)

Remove ourselves from given parentnode

Returns:None
rename(*args, **kwargs)

Rename this node to newname

Parameters:
  • newname – new name of the node
  • autocreateNamespace – if true, namespaces given in newpath will be created automatically, otherwise a RuntimeException will be thrown if a required namespace does not exist
  • renameOnClash – if true, clashing names will automatically be resolved by adjusting the name
Returns:

renamed node which is the node itself

Note:

for safety reasons, this node is dagnode aware and uses a dag modifier for them !

reparent(*args, **kwargs)

Change the parent of all nodes (also instances) to be located below parentnode

Parameters:
  • parentnode – Node instance of transform under which this node should be parented to if None, node will be reparented under the root (which only works for transforms)
  • renameOnClash – resolve nameclashes by automatically renaming the node to make it unique
  • raiseOnInstance – if True, this method will raise if you try to reparent an instanced object. If false, instanced objects will be merged into the newly created path under parentnode, effectively eliminating all other paths , keeping the newly created one
  • keepWorldSpace – if True and node to be reparented is a transform, the world space position will be kept by adjusting the transformation accordingly. WARNNG: Currently we reset pivots when doing so

:return : copy of self pointing to the new dag path self

Note:will remove all instance of this object and leave this object at only one path - if this is not what you want, use the addChild method instead as it can properly handle this case
Note:this method handles namespaces properly
resetTweaks(*args, **kwargs)

Reset the tweaks on the given mesh shape

Parameters:
  • tweak_type – the component type(s) whose tweaks are to be removed, valid values are ‘vertex’ and ‘uv’ members of the eComponentType enumeration. Pass in a scalar value or a list of tweak types
  • keep_tweak_result

    if True, the effect of the tweak will be kept. If False, it will be removed. What actually happens depends on the context

    • [referenced] mesh without history:
      copy outMesh to inMesh, resetTweaks

      if referenced, plenty of reference edits are generated, ideally one operates on non-referenced geomtry

    • [referenced] mesh with history:
      put tweakNode into mesh history, copy tweaks onto tweak node
Note:

currently vertex and uv tweaks will be removed if keep is enabled, thus they must both be specified

root()
Returns:the root of the DAG - it has no further parents
setLocked(*args, **kwargs)

Lock or unloack this node

Parameter:state – if True, the node is locked. Locked nodes cannot be deleted, renamed or reparented
Note:you can query the lock state with isLocked
setNamespace(*args, **kwargs)
Returns:

self after being moved to the given namespace. This will effectively rename the object.

Parameters:
  • newns – Namespace instance to put this Node into
  • kwargs – to be passed to rename
setParent(*args, **kwargs)

Change the parent of self to parentnode being placed at position

Parameter:kwargs – see addChild
Returns:self with updated dag path
sets(setFilter=(459, False, 0))
Returns:list of object set compatible Nodes having self as member
Parameter:setFilter – tuple(apiType, use_exact_type) - the combination of the desired api type and the exact type flag allow precise control whether you which to get only renderable shading engines, only objectfSets (tuple[1] = True), or all objects supporting the given object type. Its preset to only return shading engines
Note:the returned sets order is defined by the order connections to instObjGroups
Note:only sets will be returned that have the whole object as member, thus you will not see sets having component assignments like per-compoent shader assignments or deformer sets
shapes(predicate=<function <lambda> at 0x5e9b1b8>)
Returns:all our Shape nodes
Note:you could use getChildren with a predicate, but this method is more efficient as it uses dagpath functions to filter shapes
supports(interface_type)
Returns:True if this instance supports the interface of the given type
Parameter:interface_type – Type of the interface you require this instance to support
Note:Must be used in case you only have a weak reference of your interface instance or proxy which is a case where the ordinary isinstance( obj, iInterface ) will not work
transform()
Returns:Node to lowest transform in the path attached to our node
Note:for shapes this is the parent, for transforms the transform itself
uniformGridParams()
unparent(*args, **kwargs)
As reparent, but will unparent this transform under the scene root
vtx

Epydoc: mrv.maya.nt.geometry.SurfaceShape

class mrv.maya.nt.geometry.SurfaceShape

Bases: mrv.maya.nt.ControlPoint

addAttribute(attr)

Add the given attribute to the node as local dynamic attribute

Parameter:attr – MObject of attribute or Attribute instance as retrieved from a plug
Returns:plug to the newly added attribute
Note:This method is explicitly not undoable as attributes are being deleted in memory right in the moment they are being removed, thus they cannot reside on the undo queue
addChild(*args, **kwargs)

Add the given childNode as child to this Node. Allows instancing !

Parameters:
  • childNode – Node you wish to add
  • position – the index to which to add the new child, kNextPos will add it as last child. It supports python style negative indices
  • keepExistingParent – if True, the childNode will be instanced as it will have its previous parent(s) and this one, if False, the previous parent will be removed from the child’s parent list
  • renameOnClash – resolve nameclashes by automatically renaming the node to make it unique
  • keepWorldSpace – see reparent, only effective if the node is not instanced
Returns:

childNode whose path is pointing to the new child location

Raises ValueError:
 

if keepWorldSpace is requested with directly instanced nodes

Note:

as maya internally handles add/remove child as instancing operation, even though keepExistingParent is False, it will mess up things and for a short period of time in fact have two n + 1 instances, right before one is unlinked, This still fills a slot or something, and isInstanced will be true, although the pathcount is 1. Long story short: if the item to be added to us is not instanced, we use reparent instead. It will not harm in direct instances, so its save to use.

Note:

if the instance count of the item is 1 and keepExistingParent is False, the position argument is being ignored

addInstancedChild(*args, **kwargs)

Add childnode as instanced child to this node

Note:for more information, see addChild
Note:its a shortcut to addChild allowing to clearly indicate what is happening
addParent(*args, **kwargs)

Adds ourselves as instance to the given parentnode at position

Parameter:kwargs – see addChild
Returns:self with updated dag path
classmethod addSep(item, sep)
Returns:

item with separator added to it ( just once )

Note:

operates best on strings

Parameters:
  • item – item to add separator to
  • sep – the separator
addTo(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5c828e0> >, **kwargs)

Add ourselves to the given set

Note:method is undoable
See:sets.ObjectSet
allocateFlag()
apiObject()
Returns:our dag path as this is our api object - the object defining this node best
apiType()
Returns:the MFn Type id of the wrapped object
basename()
Returns:basename of this path, ‘/hello/world’ -> ‘world’
child(index)
Returns:child of self at index
Note:this method fixes the MFnDagNode.child method - it returns an MObject, which doesnt work well with instanced nodes - a dag path is required, which is what we use to aquire the object
childTransforms(predicate=<function <lambda> at 0x5e9b2a8>)
Returns:list of all transform nodes below this one
children(predicate=<function <lambda> at 0x5e99f50>, asNode=True)
Returns:all child nodes below this dag node if predicate returns True for passed Node
Parameter:asNode – if True, you will receive the children as wrapped Nodes, otherwise you get MDagPaths
childrenByType(nodeType, predicate=<function <lambda> at 0x5e9b0c8>)
Returns:all childnodes below this one matching the given nodeType and the predicate
Parameter:nodeType – class of the nodeTyoe, like nt.Transform
childrenDeep(order=1, predicate=<function <lambda> at 0x7f41dd7c5050>)
Returns:

list of all children of path, [ child1 , child2 ]

Parameters:
  • order – order enumeration
  • predicate – returns true if x may be returned
Note:

the child objects returned are supposed to be valid paths, not just relative paths

className()
classification()
componentAssignments(setFilter=(319, False, 0), use_api=True, asComponent=True)
Returns:

list of tuples(ObjectSetNode, Component_or_MObject) defininmg shader assignments on per component basis.

If a shader is assigned to the whole object, the component would be a null object, otherwise it is an instance of a wrapped IndexedComponent class

Note:

The returned Component will be an MObject(kNullObject) only in case the component is not set. Hence you should check whether it isNull() before actually using it.

Parameters:
  • setFilter – see connectedSets
  • use_api – if True, api methods will be used if possible which is usually faster. If False, a custom non-api implementation will be used instead. This can be required if the apiImplementation is not reliable which happens in few cases of ‘weird’ component assignments
  • asComponent – If True, the components will be wrapped into the matching MRV compontent type to provide a nicer interface. This might slightly slow down the process, but this is usually neglectable.
Note:

the sets order will be the order of connections of the respective component list attributes at instObjGroups.objectGroups

Note:

currently only meshes and subdees support per component assignment, whereas only meshes can have per component shader assignments

Note:

SubDivision Components cannot be supported as the component type kSubdivCVComponent cannot be wrapped into any component function set - reevaluate that with new maya versions !

Note:

deformer set component assignments are only returned for instance 0 ! They apply to all output meshes though

connectedSets(setFilter=(459, False, 0))
Returns:list of object set compatible Nodes having self as member
Parameter:setFilter – tuple(apiType, use_exact_type) - the combination of the desired api type and the exact type flag allow precise control whether you which to get only renderable shading engines, only objectfSets (tuple[1] = True), or all objects supporting the given object type. Its preset to only return shading engines
Note:the returned sets order is defined by the order connections to instObjGroups
Note:only sets will be returned that have the whole object as member, thus you will not see sets having component assignments like per-compoent shader assignments or deformer sets
connections()
Returns:MPlugArray of connected plugs
copyFrom(other, *args, **kwargs)

Copy the data from other into self as good as possible Only copy the data that is unique to your specific class - the data of other classes will be taken care of by them !

Note:you must support args and kwargs if one of your iDuplicate bases does

Copy lightlinks from one meshShape to another

Parameter:kwargs
  • substitute:
    if True, default False, the other shape will be put in place of self, effectively receiving it’s light-links whereas self losses them. This is practical in case you create a new shape below a transform that had a previously visible and manipulated shape whose external connections you wouuld like to keep
copyTo(instance, *args, **kwargs)

Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance

Returns:altered instance
Note:instance will be altered during the process
copyToOther(instance, *args, **kwargs)
As copyTo, but does only require the objects to have a common base. It will match the actually compatible base classes and call copyFrom if possible. As more checking is performed, this method performs worse than copyTo
createInstance(*args, **kwargs)

Create and Initialize an instance of self.__class__( ... ) based on your own data

Returns:new instance of self
Note:using self.__class__ instead of an explicit class allows derived classes that do not have anything to duplicate just to use your implementeation
Note:you must support args and kwargs if one of your iDuplicate bases does
dagPath()
Returns:the original DagPath attached to this Node - it’s not wrapped for performance
Note:If you plan to alter it, make sure you copy it using the MDagPath(node.dagPath()) construct !
deallocateAllFlags()
deallocateFlag()
delete(*args, **kwargs)

Delete this node - this special version must be

Note:if the undo queue is enabled, the object becomes invalid, but stays alive until it drops off the queue
Note:if you want to delete many nodes, its more efficient to delete them using the global delete method
dependencyInfo(attribute, by=True)
Returns:

list of attributes that given attribute affects or that the given attribute is affected by if the attribute turns dirty.

Parameters:
  • attribute – attribute instance or attribute name
  • by – if false, affected attributes will be returned, otherwise the attributes affecting this one
Note:

see also MPlug.affectedByPlugs

Note:

USING MEL: as api command and mObject array always crashed on me ... don’t know :(

displayOverrideValue(plugName)
Returns:the override display value actually identified by plugName affecting the given object (that should be a leaf node for the result you see in the viewport. The display type in effect is always the last one set in the hierarchy returns None display overrides are disabled
duplicate(*args, **kwargs)

Duplciate the given node to newpath

Parameters:
  • newpath

    result depends on its format:

    • ‘’ - empty string, creates a unique name based on the actual node name by appending a copy number to it, if newTransform is True, the newly created shape/transform will keep its name, but receives a new parent
    • ‘newname’ - relative path, the node will be duplicated not changing its current parent if newTransform is False
    • |parent|newname - absolute path, the node will be duplicated and reparented under the given path
      if newTransform is True, a new transform name will be created based on your name by appending a unique copy number
  • autocreateNamespace – if true, namespaces given in newpath will be created automatically, otherwise a RuntimeException will be thrown if a required namespace does not exist
  • renameOnClash – if true, clashing names will automatically be resolved by adjusting the name
  • newTransform – if True, a new transform will be created based on the name of the parent transform of this shape node, appending a unique copy number to it. Only has an effect for shape nodes
Returns:

newly create Node

Note:

duplicate performance could be improved by checking more before doing work that does not really change the scene, but adds undo operations

Note:

inbetween parents are always required as needed

Todo:

add example for each version of newpath

Note:

instancing can be realized using the addChild function

Note:

If meshes have tweaks applied, the duplicate will not have these tweaks and the meshes will look mislocated. Using MEL works in that case ... (they fixed it there obviously) , but creates invalid objects

Todo:

Undo implementation - every undoable operation must in fact be based on strings to really work, all this is far too much - dagNode.duplicate must be undoable by itself

Todo:

duplicate should be completely reimplemented to support all mel options and actually work with meshes and tweaks - the underlying api duplication would still be used of course, as well as connections (to sets) and so on ...

fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
classmethod getMFnClasses()
Returns:list of all function set classes this node supports, most derived function set comes first
hasChild(node)
Returns:True if node is a child of self
hasFn(mfntype)
Returns:True if our object supports the given function set type
instance(instanceNumber)
Returns:Node to the instance identified by instanceNumber
Parameter:instanceNumber – range(0, self.instanceCount()-1)
instanceNumber()
Returns:our instance number
Note:0 does not indicate that this object is not instanced - use getInstanceCount instead
isAlive()
Returns:True if the object exists in memory
Note:objects on the undo queue are alive, but NOT valid
isMemberOf(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5c1d740> >)
Returns:True if self is part of setnode
Note:method is undoable
See:sets.ObjectSet
isPartOf(other)
Returns:True if self is a part of other, and thus can be found in other
Note:operates on strings only
isRoot()
Returns:True if this path is the root of the DAG
isRootOf(other)
Returns:True other starts with self
Note:operates on strings
Note:we assume other has the same type as self, thus the same separator
isTemplate()
Returns:True if this node is templated - this is the case if itself or one of its parents are templated
isValid()
Returns:True if the object exists in the scene
Note:Handles DAG objects correctly that can be instanced, in which case the MObject may be valid , but the respective dag path is not. Additionally, if the object is not parented below any object, everything appears to be valid, but the path name is empty
isVisible()
Returns:True if this node is visible - its visible if itself and all parents are visible
iterInstances(excludeSelf=False)

Get iterator over all (direct and indirect)instances of this node

Parameter:excludeSelf – if True, self will not be returned, if False, it will be in the list of items
Note:Iterating instances is more efficient than querying all instances individually using instance
Todo:add flag to allow iteration of indirect instances as well
iterParents(predicate=<function <lambda> at 0x7f41dd7c5230>)
Returns:generator retrieving all parents up to the root
Parameter:predicate – returns True for all x that you want to be returned
name()
Returns:fully qualified (long) name of this dag node
object()
Returns:MObject as retrieved from the MDagPath of our Node
parent()
Returns:Maya node of the parent of this instance or None if this is the root
parentAtIndex(index)
Returns:Node of the parent at the given index - non-instanced nodes only have one parent
Note:if a node is instanced, it can have parentCount parents
Todo:Update dagpath afterwards ! Use dagpaths instead !
parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
referenceFile()
Returns:name (str) of file this node is coming from - it could contain a copy number as {x}
Note:will raise if the node is not referenced, use isReferenced to figure that out
removeAttribute(attr)

Remove the given attribute from the node

Parameter:attr – see addAttribute
removeChild(*args, **kwargs)

remove the given childNode (being a child of this node) from our child list, effectively parenting it under world !

Parameters:
  • childNode – Node to unparent - if it is not one of our children, no change takes place
  • allowZeroParents – if True, it is possible to leave a node unparented, thus no valid dag paths leads to it. If False, transforms will just be reparented under the world
Returns:

copy of childnode pointing to the first valid dag path we find.

Note:

to prevent the child (if transform) to dangle in unknown space if the last instance is to be removed, it will instead be reparented to world.

Note:

removing shapes from their last parent will result in an error

removeFrom(setnode, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5b41420> >)

remove ourselves to the given set

Note:method is undoable
See:sets.ObjectSet
removeParent(*args, **kwargs)

Remove ourselves from given parentnode

Returns:None
rename(*args, **kwargs)

Rename this node to newname

Parameters:
  • newname – new name of the node
  • autocreateNamespace – if true, namespaces given in newpath will be created automatically, otherwise a RuntimeException will be thrown if a required namespace does not exist
  • renameOnClash – if true, clashing names will automatically be resolved by adjusting the name
Returns:

renamed node which is the node itself

Note:

for safety reasons, this node is dagnode aware and uses a dag modifier for them !

reparent(*args, **kwargs)

Change the parent of all nodes (also instances) to be located below parentnode

Parameters:
  • parentnode – Node instance of transform under which this node should be parented to if None, node will be reparented under the root (which only works for transforms)
  • renameOnClash – resolve nameclashes by automatically renaming the node to make it unique
  • raiseOnInstance – if True, this method will raise if you try to reparent an instanced object. If false, instanced objects will be merged into the newly created path under parentnode, effectively eliminating all other paths , keeping the newly created one
  • keepWorldSpace – if True and node to be reparented is a transform, the world space position will be kept by adjusting the transformation accordingly. WARNNG: Currently we reset pivots when doing so

:return : copy of self pointing to the new dag path self

Note:will remove all instance of this object and leave this object at only one path - if this is not what you want, use the addChild method instead as it can properly handle this case
Note:this method handles namespaces properly
root()
Returns:the root of the DAG - it has no further parents
setLocked(*args, **kwargs)

Lock or unloack this node

Parameter:state – if True, the node is locked. Locked nodes cannot be deleted, renamed or reparented
Note:you can query the lock state with isLocked
setNamespace(*args, **kwargs)
Returns:

self after being moved to the given namespace. This will effectively rename the object.

Parameters:
  • newns – Namespace instance to put this Node into
  • kwargs – to be passed to rename
setParent(*args, **kwargs)

Change the parent of self to parentnode being placed at position

Parameter:kwargs – see addChild
Returns:self with updated dag path
sets(setFilter=(459, False, 0))
Returns:list of object set compatible Nodes having self as member
Parameter:setFilter – tuple(apiType, use_exact_type) - the combination of the desired api type and the exact type flag allow precise control whether you which to get only renderable shading engines, only objectfSets (tuple[1] = True), or all objects supporting the given object type. Its preset to only return shading engines
Note:the returned sets order is defined by the order connections to instObjGroups
Note:only sets will be returned that have the whole object as member, thus you will not see sets having component assignments like per-compoent shader assignments or deformer sets
shapes(predicate=<function <lambda> at 0x5e9b1b8>)
Returns:all our Shape nodes
Note:you could use getChildren with a predicate, but this method is more efficient as it uses dagpath functions to filter shapes
supports(interface_type)
Returns:True if this instance supports the interface of the given type
Parameter:interface_type – Type of the interface you require this instance to support
Note:Must be used in case you only have a weak reference of your interface instance or proxy which is a case where the ordinary isinstance( obj, iInterface ) will not work
transform()
Returns:Node to lowest transform in the path attached to our node
Note:for shapes this is the parent, for transforms the transform itself
unparent(*args, **kwargs)
As reparent, but will unparent this transform under the scene root

Epydoc: mrv.maya.nt.geometry._SingleIndexedComponentGenerator

class mrv.maya.nt.geometry._SingleIndexedComponentGenerator(mesh, component)

Bases: object

Utility producing components, initialized with the given indices. See Mesh for more info.

empty()
Returns:empty component of our type

Epydoc: mrv.maya.nt.geometry._SingleIndexedComponentIterator

class mrv.maya.nt.geometry._SingleIndexedComponentIterator(mesh, component)

Bases: mrv.maya.nt.geometry._SingleIndexedComponentGenerator

Utility which produces iterators for the component type it was initialized with. As a bonus, it allows to return quick constrained iterators using the slice and get-item notation

empty()
Returns:empty component of our type
iter
Returns:Iterator for all components in the mesh
iterator()
Returns:Iterator for all components in the mesh

Epydoc: mrv.maya.nt.geometry

Table Of Contents

Previous topic

mrv.maya.nt.storage

Next topic

mrv.automation.process

This Page