Contains different multi-purpose iterators allowing to conveniently walk the dg and dag.
Returns: | MItDagIterator configured according to args - see docs at iterDagNodes. |
---|---|
Note: | use this method if you want to use more advanced features of the iterator |
Returns: | MItDependencyNodes configured according to args - see docs at iterDgNodes. |
---|---|
Note: | use this method if you want to use more advanced features of the iterator |
Returns: | MItDependencyGraph configured according to args - see docs at iterGraph. |
---|---|
Note: | use this method if you want to use more advanced features of the iterator |
Raises RuntimeError: | |
if the filter types does not allow any nodes to be returned. This is a bug in that sense as it should just return nothing. It also shows that maya pre-parses the result and then just iterates over a list with the iterator in question |
Iterate over the hierarchy under a root dag node, if root is None, will iterate on whole Maya scene If a list of types is provided, then only nodes of these types will be returned, if no type is provided all dag nodes under the root will be iterated on. Types are specified as Maya API types being a member of api.MFn The following keywords will affect order and behavior of traversal:
Parameter: | kwargs –
|
---|
Iterator on MObjects or Nodes of the specified api.MFn types
Parameters: |
|
---|
Iterate Dependency Graph (DG) Nodes or Plugs starting at a specified root Node or Plug. The iteration _includes_ the root node or plug. The following keywords will affect order and behavior of traversal:
Parameters: |
|
---|---|
Returns: | Iterator yielding MObject, Node or Plug depending on the configuration flags, first yielded item is always the root node or plug. |
Iterate the given selection list
Parameters: |
|
---|---|
Returns: | Node or Plug on each iteration step If handleComponents is True, for each Object, a tuple will be returned as tuple( Node, Component ) where component is NullObject ( MObject ) if the whole object is on the list. If the original object was a plug, it will be in the tuples first slot, whereas the component will be a NullObject |
Returns: | iterator suitable to iterate given selection list - for more info see iterSelectionList |
---|
Bases: maya.OpenMaya.MObject, mrv.maya.nt._root_
Represents a shape component - its derivates can be used to handle component lists to be used in object sets and shading engines
see addElements
Returns: | self |
---|---|
Note: | do not use this function as it will be really slow when handling many items, use addElements instead |
Operates exactly as described in the MFn...IndexComponent documentation, but returns self to allow combined calls and on-the-fly component generation
Returns: | self |
---|
Returns: | A new component instance carrying data of the given component type |
---|---|
Parameter: | component_type – MFn:: component type to be created. |
Note: | It is important that you call this function on the Component Class of a compatible type, or a RuntimeError will occour |
Returns: | mfn type of this class |
---|---|
Note: | the type returned is not the type of the shape component |
Bases: mrv.maya.nt.Entity, mrv.interface.iDagItem
Implements access to DAG nodes
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 |
Add the given childNode as child to this Node. Allows instancing !
Parameters: |
|
---|---|
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 |
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 |
Adds ourselves as instance to the given parentnode at position
Parameter: | kwargs – see addChild |
---|---|
Returns: | self with updated dag path |
Returns: | item with separator added to it ( just once ) |
---|---|
Note: | operates best on strings |
Parameters: |
|
Add ourselves to the given set
Note: | method is undoable |
---|---|
See: | sets.ObjectSet |
Returns: | our dag path as this is our api object - the object defining this node best |
---|
Returns: | the MFn Type id of the wrapped object |
---|
Returns: | basename of this path, ‘/hello/world’ -> ‘world’ |
---|
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 |
Returns: | list of all transform nodes below this one |
---|
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 |
Returns: | all childnodes below this one matching the given nodeType and the predicate |
---|---|
Parameter: | nodeType – class of the nodeTyoe, like nt.Transform |
Returns: | list of all children of path, [ child1 , child2 ] |
---|---|
Parameters: |
|
Note: | the child objects returned are supposed to be valid paths, not just relative paths |
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 |
Returns: | MPlugArray of connected plugs |
---|
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 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 |
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 |
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 ! |
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 |
Returns: | list of attributes that given attribute affects or that the given attribute is affected by if the attribute turns dirty. |
---|---|
Parameters: |
|
Note: | see also MPlug.affectedByPlugs |
Note: | USING MEL: as api command and mObject array always crashed on me ... don’t know :( |
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 |
---|
Duplciate the given node to newpath
Parameters: |
|
---|---|
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 ... |
Returns: | list of all function set classes this node supports, most derived function set comes first |
---|
Returns: | True if node is a child of self |
---|
Returns: | True if our object supports the given function set type |
---|
Returns: | Node to the instance identified by instanceNumber |
---|---|
Parameter: | instanceNumber – range(0, self.instanceCount()-1) |
Returns: | our instance number |
---|---|
Note: | 0 does not indicate that this object is not instanced - use getInstanceCount instead |
Returns: | True if the object exists in memory |
---|---|
Note: | objects on the undo queue are alive, but NOT valid |
Returns: | True if self is part of setnode |
---|---|
Note: | method is undoable |
See: | sets.ObjectSet |
Returns: | True if self is a part of other, and thus can be found in other |
---|---|
Note: | operates on strings only |
Returns: | True if this path is the root of the DAG |
---|
Returns: | True other starts with self |
---|---|
Note: | operates on strings |
Note: | we assume other has the same type as self, thus the same separator |
Returns: | True if this node is templated - this is the case if itself or one of its parents are templated |
---|
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 |
Returns: | True if this node is visible - its visible if itself and all parents are visible |
---|
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 |
Returns: | generator retrieving all parents up to the root |
---|---|
Parameter: | predicate – returns True for all x that you want to be returned |
Returns: | fully qualified (long) name of this dag node |
---|
Returns: | MObject as retrieved from the MDagPath of our Node |
---|
Returns: | Maya node of the parent of this instance or None if this is the root |
---|
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 ! |
Returns: | all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ] |
---|
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 |
Remove the given attribute from the node
Parameter: | attr – see addAttribute |
---|
remove the given childNode (being a child of this node) from our child list, effectively parenting it under world !
Parameters: |
|
---|---|
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 |
remove ourselves to the given set
Note: | method is undoable |
---|---|
See: | sets.ObjectSet |
Remove ourselves from given parentnode
Returns: | None |
---|
Rename this node to newname
Parameters: |
|
---|---|
Returns: | renamed node which is the node itself |
Note: | for safety reasons, this node is dagnode aware and uses a dag modifier for them ! |
Change the parent of all nodes (also instances) to be located below parentnode
Parameters: |
|
---|
: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 |
Returns: | the root of the DAG - it has no further parents |
---|
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 |
Returns: | self after being moved to the given namespace. This will effectively rename the object. |
---|---|
Parameters: |
|
Change the parent of self to parentnode being placed at position
Parameter: | kwargs – see addChild |
---|---|
Returns: | self with updated dag path |
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 |
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 |
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 |
Returns: | Node to lowest transform in the path attached to our node |
---|---|
Note: | for shapes this is the parent, for transforms the transform itself |
Bases: object
Bases: object
Bases: object
Common base for all maya nodes, providing access to the maya internal object representation Use this class to directly create a maya node of the required type
Returns: | the highest qualified api object of the actual superclass, usually either MObject or MDagPath |
---|
Returns: | the MFn Type id of the wrapped object |
---|
Returns: | list of all function set classes this node supports, most derived function set comes first |
---|
Returns: | True if our object supports the given function set type |
---|
Bases: object
Virtual Constructor, producing nodes as the Node does, but it will only accept MObjects or dagpaths which are expected to be valid. As no additional checking is performed, it might be more unsafe to use, but will be faster as it does not perform any runtime checks
It duplicates code from _checkedInstanceCreation and _checkedInstanceCreationDagPathSupport to squeeze out the last tiny bit of performance as it can make quite a few more assumptions and reduces method calls.
Note: | Do not derive from this class, derive from Node instead |
---|---|
Note: | We will always create the node type as determined by the type hierarchy |