mrv.maya.nt.storage

Epydoc: mrv.maya.nt.storage

Contains an implementation for the Persistence plugin for easy access within mrv and derived nodes.

Functions

mrv.maya.nt.storage._makeElementPlug(*args, **kwargs)
Find an empty logical plug index and return the newly created logical plug with given dataID - unconditionally
mrv.maya.nt.storage.clearAllData(*args, **kwargs)
Empty all data storage plugs beneath the given masterPlug. Message connections are currently not affected
mrv.maya.nt.storage.clearDataPlug(vdplug)
Clear the data in the given value data plug
mrv.maya.nt.storage.createNode(*args, **kwargs)

Create a new node of nodetype with given nodename

Parameters:
  • nodename – like mynode``or ``namespace:mynode or |parent|mynode or |ns1:parent|ns1:ns2:parent|ns3:mynode. The name may contain any amount of parents and/or namespaces.
  • nodetype – a nodetype known to maya to be created accordingly
  • autocreateNamespace – if True, namespaces given in the nodename will be created if required
  • renameOnClash – if True, nameclashes will automatcially be resolved by creating a unique name - this only happens if a dependency node has the same name as a dag node
  • forceNewLeaf – if True, nodes will be created anyway if a node with the same name already exists - this will recreate the leaf portion of the given paths. Implies renameOnClash If False, you will receive an already existing node if the name and type matches.
  • maxShapesPerTransform – only used when renameOnClash is True, defining the number of shapes you may have below a transform. If the number would be exeeded by the creation of a shape below a given transform, a new auto-renamed transform will be created automatically. This transform is garantueed to be new and will be used as new parent for the shape.
Note:

For reasons of safety, dag nodes must use absolute paths like |parent|child - otherwise names might be ambiguous ! This method will assume absolute paths !

Raises RuntimeError:
 

If nodename contains namespaces or parents that may not be created

Raises NameError:
 

If name of desired node clashes as existing node has different type

Note:

As this method is checking a lot and tries to be smart, its relatively slow (creates ~1200 nodes / s)

Returns:

the newly create Node

mrv.maya.nt.storage.dataIDs(masterPlug, data_prefix='')
Returns:list of all data ids available in the given master plug
Parameter:data_prefix – the string prefix of data names which must match with the prefix of the data id to be returned, with the matching prefix pruned. By default, all data ids will match
mrv.maya.nt.storage.delete(*args, **kwargs)

Delete the given nodes

Parameters:
  • args – Node instances, MObjects, MDagPaths or strings to delete
  • kwargs
    • presort:
      if True, default False, will do alot of pre-work to actually make the deletion work properly using the UI, thus we sort dag nodes by dag path token length to delete top level ones first and individually, to finally delete all dependency nodes in a bunch

    Using this flag will be slower, but yields much better results if deleting complex dag and dependency trees with locked attributes, conversion nodes, transforms and shapes

Note:

in general , no matter which options have been chosen , api deletion does not work well as the used algorithm is totally different and inferior to the mel implementaiton

Note:

will not raise in case of an error, but print a notification message

Note:

all deletions will be stored on one undo operation

mrv.maya.nt.storage.deleteObjectSet(*args, **kwargs)

Delete the object set at the given message data plug, at the given setIndex :note: use this method to delete your sets instead of manual deletion as it will automatically

remove the managed partition in case the last set is being deleted
mrv.maya.nt.storage.findStoragePlug(masterPlug, dataID)
Returns:compound plug containing all data and connections for the given dataID
Parameter:masterPlug – compound plug containing all data
mrv.maya.nt.storage.makePlug(*args, **kwargs)

retrieve or create a plug that corresponds to the given dataID :param dataID: string identifier :return: the created data plug, containing subplugs dval and dmsg

for generic data and message connections respectively
mrv.maya.nt.storage.objectSet(*args, **kwargs)

Get an object set identified with setIndex at the given dataId

Parameters:
  • mdplug – data message plug whose object set to handle
  • setIndex – logical index at which the set will be connected to our message plug array
  • autoCreate – if True, a set will be created if it does not yet exist
  • setPrefix – if given, the string will be used as prefix for the name of newly created object sets
Raises ValueError:
 

if a set does not exist at setIndex and autoCreate is False

Raises AttributeError:
 

if the plug did not exist (and autocreate is False)

Note:

method is implicitly undoable if autoCreate is True, this also means that you cannot explicitly undo this operation as you do not know if undo has been queued or not

Note:

newly created sets will automatically use partitions if one of the sets does

mrv.maya.nt.storage.partition(mdplug)
Returns:parition node attached to the sets of the given message data plug or None
mrv.maya.nt.storage.setPartition(*args, **kwargs)
Make all sets of the given data message plug use a partition or not :param state: if True, a partition will be used, if False, it will be disabled :note: this method makes sure that all sets are hooked up to the partition :raise ValueError: If we did not have a single set to which to add to the partition :raise AttributeError: If the dataID has never had sets :return: if state is True, the name of the possibly created (or existing) partition
mrv.maya.nt.storage.setsByPlug(mdplug)
Returns:all objectSets stored at the given message data plug
mrv.maya.nt.storage.storagePlug(*args, **kwargs)
Returns:

plug of the given type, either as tuple of two plugs or the plug specified by plugType

Parameters:
  • masterPlug – masterPlug to search for data
  • dataID – the name of the plug to be returned
  • plugType – StorageBase.kMessage: return message array plug only StorageBase.kValue: return python pickle array plug only StorageBase.kStorage: return the storage plug itself containing message and the value plug StorageBase.kFlags return plug to integer which can be used as storage for bitflags to accompany the id None: return (picklePlug , messagePlug)
  • autoCreate – if True, a plug with the given dataID will be created if it does not yet exist
Raises AttributeError:
 

if a plug with dataID does not exist and default value is None

Raises TypeError:
 

if plugtype unknown

Classes

Epydoc: mrv.maya.nt.storage

class mrv.maya.nt.storage.Data(*args)

Bases: maya.OpenMaya.MObject, mrv.maya.nt._root_

Represents an data in general - this is the base class Use this general class to create data wrap objects - it will return a class of the respective type

apiType()
apiTypeStr()
assign()
className()
classmethod create(*args, **kwargs)
Returns:A new instance of data wrapped in the desired Data type
Note:specialize this method in derived types !
hasFn()
isNull()
kNullObj
thisown
The membership flag

Epydoc: mrv.maya.nt.storage

class mrv.maya.nt.storage.DependNode

Bases: mrv.maya.nt.Node, mrv.interface.iDuplicatable

Implements access to dependency nodes

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
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:the MObject attached to this Node
apiType()
Returns:the MFn Type id of the wrapped object
basename()
Returns:name of this instance
Note:it is mainly for compatability with dagNodes which need this method in order to return the name of their leaf node
children(predicate=<function <lambda> at 0x7f41dd7c2ed8>)
Returns:list of intermediate children of path, [ child1 , child2 ]
Parameter:predicate – return True to include x in result
Note:the child objects returned are supposed to be valid paths, not just relative paths
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()
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
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
deallocateAllFlags()
deallocateFlag()
delete(*args, **kwargs)

Delete this node

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 :(

duplicate(*args, **kwargs)

Duplicate our node and return a wrapped version to it

Parameters:
  • name – if given, the newly created node will use the given name
  • kwargs
    • renameOnClash: if Trrue, default True, clashes are prevented by renaming the new node
    • autocreateNamespace: if True, default True, namespaces will be created if mentioned in the name
Note:

the copyTo method may not have not-undoable side-effects to be a proper implementation

Note:

undo could be implemented for dg nodes - but for reasons of consistency, its disabled here - who knows how much it will crap out after a while as duplicate is not undoable (mel command) - it never really worked to undo a mel command from within python, executed using a dgmodifier - unfortunately it does not return any result making it hard to find the newly duplicated object !

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
hasFn(mfntype)
Returns:True if our object supports the given function set type
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
isValid()
Returns:True if the object exists in the scene
Note:objects on the undo queue are NOT valid, but alive
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
object()
Returns:the MObject attached to this Node
parent()
Returns:parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root
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
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
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 !

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
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
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

Epydoc: mrv.maya.nt.storage

class mrv.maya.nt.storage.MFnDependencyNode(*args)

Bases: maya.OpenMaya.MFnBase

addAttribute()
allocateFlag()
attribute()
attributeClass()
attributeCount()
canBeWritten()
className()
classification()
create()
deallocateAllFlags()
deallocateFlag()
dgCallbackIds()
dgCallbacks()
dgTimer()
dgTimerOff()
dgTimerOn()
dgTimerQueryState()
dgTimerReset()
findAlias()
findPlug()
getAffectedAttributes()
getAffectedByAttributes()
getAliasAttr()
getAliasList()
getConnections()
hasAttribute()
hasObj()
hasUniqueName()
icon()
isDefaultNode()
isFlagSet()
isFromReferencedFile()
isLocked()
isNewAttribute()
isShared()
name()
object()
parentNamespace()
pluginName()
plugsAlias()
removeAttribute()
reorderedAttribute()
setAlias()
setDoNotWrite()
setFlag()
setIcon()
setLocked()
setName()
setObject()
thisown
The membership flag
type()
typeId()
typeName()
userNode()

Epydoc: mrv.maya.nt.storage

class mrv.maya.nt.storage.Node

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

apiObject()
Returns:the highest qualified api object of the actual superclass, usually either MObject or MDagPath
apiType()
Returns:the MFn Type id of the wrapped object
classmethod getMFnClasses()
Returns:list of all function set classes this node supports, most derived function set comes first
hasFn(mfntype)
Returns:True if our object supports the given function set type

Epydoc: mrv.maya.nt.storage

class mrv.maya.nt.storage.ObjectSet

Bases: mrv.maya.nt.Entity

Extended and more convenient object set interface dealing with Nodes ( and provides the original MFnSet interface as well

add(*args, **kwargs)

Combined method which takes single or multiple members which are to be added

Parameters:
  • member_or_members – one of the input types supported by addMember and addMembers
  • kwargs – see addMember
Note:

this method is for convenience only and should not be used to add massive amounts of items

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
addMember(*args, **kwargs)

Add the item to the set

Parameters:
  • member – Node, MObject, MDagPath or plug
  • force – if True, member ship will be forced by removing the member in question from the other set connected to our partitions
  • ignore_failure – if True, a failed add due to partion constraints will result in an exception, otherwise it will be silently ignored. Ignored if if force is True
  • component – if member is a dagnode, you can specify a component instance of type component instance ( Single|Double|TripleIndexComponent )
Todo:

handle components - currently its only possible when using selection lists

Returns:

self

addMembers(*args, **kwargs)

Add items from iterable or selection list as members to this set

Parameters:
  • nodes – MSelectionList or list of Nodes and Plugs
  • force – see addMember
  • ignore_failure – see addMember
Returns:

self

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:the MObject attached to this Node
apiType()
Returns:the MFn Type id of the wrapped object
basename()
Returns:name of this instance
Note:it is mainly for compatability with dagNodes which need this method in order to return the name of their leaf node
children(predicate=<function <lambda> at 0x7f41dd7c2ed8>)
Returns:list of intermediate children of path, [ child1 , child2 ]
Parameter:predicate – return True to include x in result
Note:the child objects returned are supposed to be valid paths, not just relative paths
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()
clear(*args, **kwargs)

Clear the set so that it will be empty afterwards

Returns:self
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
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
deallocateAllFlags()
deallocateFlag()
delete(*args, **kwargs)

Delete this node

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 :(

difference(objects, sets_are_members=False)

return the result of self minus objects, thus objects will be substracted from our obejcts

Parameters:
  • objects – see union
  • sets_are_members – see union
Returns:

MSelectionList containing objects of self not being in objects list

discard(*args, **kwargs)

Removes a single member or multiple members from the set

Parameters:
  • member_or_members – any of the types supported by removeMember or removeMembers
  • kwargs – see removeMember
duplicate(*args, **kwargs)

Duplicate our node and return a wrapped version to it

Parameters:
  • name – if given, the newly created node will use the given name
  • kwargs
    • renameOnClash: if Trrue, default True, clashes are prevented by renaming the new node
    • autocreateNamespace: if True, default True, namespaces will be created if mentioned in the name
Note:

the copyTo method may not have not-undoable side-effects to be a proper implementation

Note:

undo could be implemented for dg nodes - but for reasons of consistency, its disabled here - who knows how much it will crap out after a while as duplicate is not undoable (mel command) - it never really worked to undo a mel command from within python, executed using a dgmodifier - unfortunately it does not return any result making it hard to find the newly duplicated object !

fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
getDifference(objects, sets_are_members=False)

return the result of self minus objects, thus objects will be substracted from our obejcts

Parameters:
  • objects – see union
  • sets_are_members – see union
Returns:

MSelectionList containing objects of self not being in objects list

getIntersection(objects, sets_are_members=False)

As union, but returns the intersection ( items in common ) of this set with objects

Parameters:
  • objects – see union
  • sets_are_members – see union
Returns:

MSelectionList of objects being in self and in objects

classmethod getMFnClasses()
Returns:list of all function set classes this node supports, most derived function set comes first
getMembers(flatten=False)
Returns:MSelectionList with members of this set
Parameter:flatten – if True, members that are objectSets themselves will be resolved to their respective members
Note:the members are ordinary api objects that still need to be wrapped
Note:use iterMembers to iterate the members as wrapped Nodes
getUnion(objects, sets_are_members=False)

Create a union of the given items with the members of this set

Parameters:
  • objects – an ObjectSet, an MObject of an object set, a list of ObjectSets or a list of wrapped Objects or an MSelectionList or a single wrapped object . If you have objects in a list as well as sets themselves, objects must come first as the operation will fail otherwise.
  • sets_are_members – if True, objects can contain sets, but they should not be treated as sets to apply the set operation with, they should simply be members of this set, and thus need to be wrapped into a tmp set as well
Returns:

MSelectionList of all objects of self and objects

hasFn(mfntype)
Returns:True if our object supports the given function set type
intersection(objects, sets_are_members=False)

As union, but returns the intersection ( items in common ) of this set with objects

Parameters:
  • objects – see union
  • sets_are_members – see union
Returns:

MSelectionList of objects being in self and in objects

isAlive()
Returns:True if the object exists in memory
Note:objects on the undo queue are alive, but NOT valid
isMember(obj, component=<maya.OpenMaya.MObject; proxy of <Swig Object of type 'MObject *' at 0x5e387a0> >)
Returns:True if obj is a member of this set
Parameter:component – is given, the component must be fully part of the set for the object ( dagNode ) to be considered part of the set
Note:all keywords of it.iterSelectionList are supported
Note:ismember does not appear to be working properly with component assignments. It returns true for components that are not actually in the givne shading group
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
isValid()
Returns:True if the object exists in the scene
Note:objects on the undo queue are NOT valid, but alive
iterDifference(setOrSetsOrObjects, **kwargs)

As difference, but returns an iterator

Parameter:kwargs – passed to it.iterSelectionList
iterIntersection(setOrSetsOrObjects, **kwargs)

As intersection, but returns an iterator

Parameter:kwargs – passed to it.iterSelectionList
iterMembers(*args, **kwargs)

Iterate members of this set

Note:All keywords of iterMembers are supported
Note:if ‘handlePlugs’ is False, the iteration using a filter type will be faster
Note:handleComponents will allow component iteration - see the iterator documentation
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
iterUnion(setOrSetsOrObjects, **kwargs)

As union, but returns an iterator

Parameter:kwargs – passed to it.iterSelectionList
members(flatten=False)
Returns:MSelectionList with members of this set
Parameter:flatten – if True, members that are objectSets themselves will be resolved to their respective members
Note:the members are ordinary api objects that still need to be wrapped
Note:use iterMembers to iterate the members as wrapped Nodes
object()
Returns:the MObject attached to this Node
parent()
Returns:parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root
parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
partitions()
Returns:list of Nodes of partitions the entity is set is part of
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
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
removeMember(*args, **kwargs)

Remove the member from the set

Parameter:member – member of the list, for types see addMember
removeMembers(*args, **kwargs)

Remove items from iterable or selection list from this set

Parameter:nodes – see addMembers
Returns:self
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 !

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
setMembers(*args, **kwargs)

Adjust set membership for nodes

Parameters:
  • nodes – items to handle, supports everything that addMembers does
  • kwargs – arguments passed to addMembers or removeMembers
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
setPartition(*args, **kwargs)

Add, add exclusive or remove the given partition from our partition list

Parameters:
  • partition – Node, representing the partition, or a list of such
  • mode
    • 0 = replace
    • 1 = add
    • 2 = remove
Returns:

self for chained operations

Note:

use the supplied enumeration to specify the mode

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
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
classmethod tmpSet(objects, sets_are_members=False)
Returns:

temporary set that will delete itself once it’s reference count reaches 0. Use rval.setobj to access the actual set, as the returned object is just a hanlde to it. The handle is a valid input to the set functions as well

Parameters:
  • objects – see union
  • sets_are_members – see union
Note:

useful if you want to use the set member union, intersection or substraction methods efficiently on many sets in a row - these internally operate on a set, thus it is faster to use them with another set from the beginning to prevent creation of intermediate sets

union(objects, sets_are_members=False)

Create a union of the given items with the members of this set

Parameters:
  • objects – an ObjectSet, an MObject of an object set, a list of ObjectSets or a list of wrapped Objects or an MSelectionList or a single wrapped object . If you have objects in a list as well as sets themselves, objects must come first as the operation will fail otherwise.
  • sets_are_members – if True, objects can contain sets, but they should not be treated as sets to apply the set operation with, they should simply be members of this set, and thus need to be wrapped into a tmp set as well
Returns:

MSelectionList of all objects of self and objects

Epydoc: mrv.maya.nt.storage

class mrv.maya.nt.storage.PyPickleData

Bases: maya.OpenMayaMPx.MPxData

Allows to access a pickled data object natively within a maya file. In ascii mode, the pickle will be encoded into string data, in binary mode the cPickle will be taken in its original value.

To get the respective dict-references back, we use a tracking dict as proposed by the API Docs

Note:This datatype is copies the data by reference which is why maya always calls the copy constructor, even if you retrieve a const data reference, where this would not be required actually. This is fine for most uses
Note:as the datatype is reference based, undo is currently not supported (or does not work as it is expected to do
copy(other)
Copy other into self - allows copy pointers as maya copies the data each time you retrieve it
static creator()
name()
readASCII(args, lastParsedElement)
Read base64 element and decode to cStringIO, then unpickle
readBinary(inStream, numBytesToRead)

Read in 4 byte packs to cStringIO, unpickle from there

Note:this method is more complicated than it needs be since asCharPtr does not work ! It returns a string of a single char ... which is not the same :) !
Note:YES, this is a CUMBERSOME way to deal with bytes ... terrible, thanks maya :), thanks python
thisown
The membership flag
typeId()
writeASCII(out)
cPickle to cStringIO, encode with base64 encoding
writeBinary(out)
cPickle to cStringIO, write in 4 byte packs using ScriptUtil

Epydoc: mrv.maya.nt.storage.StorageBase

class mrv.maya.nt.storage.StorageBase(data_prefix='', maya_node=None, attr_prefix='')

Bases: mrv.interface.iDuplicatable

A storage node contains a set of attributes allowing it to store python data and objects being stored in a pickled format upon file save. Additionally you can store connections. Nodes used with this interface must be compatible to the following attribute scheme. To create that scheme, use createStorageAttribute

Attribute Setup:

(shortname (description) [data type])
dta (data)[multi compound]
        id (data id)[string]
        type (data type) [int]  # for your own use, store bitflags to specify attribute
        dval (data value) [python pickle]
        dmsg (data message)[multi message]

Configuration:

data_prefix: will prefix every value name when setting and getting values - this allows
        several clients to use the same storage attribute (on the same node for example)
        It acts like a namespace
attr_prefix: prefixes the actual maya attribute to access
maya_node: the maya node holding the actual attributes
Note:A mrv node should derive from this class to allow easy attribute access of its own compatible attributes - its designed for flexiblity
Note:attribute accepts on the generic attribute should be set by a plugin node when it creates its attributes
Todo:should self._node be stored as weakref ?
class PyPickleValue(valueplug, pythondata)

Bases: object

Wrapper object prividing native access to the wrapped python pickle object and to the corresponding value plug, providing utlity methods for easier handling

isReferenced()
Returns:True if the data is from a referenced plug
classmethod StorageBase.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
StorageBase.attributePrefix()
Returns:our attribute prefix
StorageBase.basename()
Returns:basename of this path, ‘/hello/world’ -> ‘world’
StorageBase.children(predicate=<function <lambda> at 0x7f41dd7c2ed8>)
Returns:list of intermediate children of path, [ child1 , child2 ]
Parameter:predicate – return True to include x in result
Note:the child objects returned are supposed to be valid paths, not just relative paths
StorageBase.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

StorageBase.clearAllData(*args, **kwargs)

see clearAllData module level method :note: use this method if you want to make sure your node

is empty after it has been duplicated (would usually be done in the postContructor
StorageBase.clearData(*args, **kwargs)
Clear all data stored in the given dataID
StorageBase.copyFrom(other, *args, **kwargs)

Copy all values from other to ourselves

Parameter:kwargs
  • shallow:
    if True, default False, only a shallow copy will be made. If False, a deep copy will be made
Note:only does so if the attribute and data prefixes actually match (which should be the case if we get here, checking for it anyway
Note:as pickle data always copies by reference to be efficient, we have to explicitly create new data to assure we really copy it
Todo:copy connections to our messages as well, make it an option at least
StorageBase.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
StorageBase.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
StorageBase.createInstance(*args, **kwargs)
Create a new instance with our type
StorageBase.dataIDs()
see module level function with the same name
StorageBase.dataPrefix()
Returns:our data prefix
StorageBase.deleteObjectSet(*args, **kwargs)
See the module level method called deleteObjectSet
StorageBase.duplicate(*args, **kwargs)

Implements a c-style copy constructor by creating a new instance of self and applying the copyFrom methods from base to all classes implementing the copyfrom method. Thus we will call the method directly on the class

Parameters:
  • args – passed to copyFrom and createInstance method to give additional directions
  • kwargs – see param args
StorageBase.findStoragePlug(dataID)
Returns:compound plug with given dataID or None
StorageBase.fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
StorageBase.isPartOf(other)
Returns:True if self is a part of other, and thus can be found in other
Note:operates on strings only
StorageBase.isRoot()
Returns:True if this path is the root of the DAG
StorageBase.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
StorageBase.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
StorageBase.makePlug(dataID)
see makePlug module level function
StorageBase.masterPlug()
Returns:master plug according to our attributePrefix
StorageBase.objectSet(*args, **kwargs)
see module level objectSet function
StorageBase.parent()
Returns:parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root
StorageBase.parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
StorageBase.partition(dataID)
Returns:partition Node attached to the sets at dataID or None if state is disabled
StorageBase.pythonData(dataID, **kwargs)
Returns:

PyPickleVal object at the given index (it can be modified natively)

Parameters:
  • dataID – id of of the data to retrieve
  • kwargs
    • index:
      element number of the plug to retrieve, or -1 to get a new plug. Plugs will always be created, the given index specifies a logical plug index
    • Additionally all arguments supported by storagePlug
classmethod StorageBase.pythonDataFromPlug(valplug)

Exract the python data using the given plug directly

Parameter:valplug – data value plug containing the plugin data
Returns:PyPickleData object allowing data access
StorageBase.root()
Returns:the root of the DAG - it has no further parents
StorageBase.setAttributePrefix(prefix)
Change the prefix with which to access to the actual storage data attributes on our node to the given string
StorageBase.setDataPrefix(prefix)
Change the data prefix to the given value string
StorageBase.setPartition(*args, **kwargs)
see setPartition function on module level
StorageBase.setStorageNode(node)

Set ourselves to use the given storage compatible node

Note:use this if the path of our instance has changed - otherwise trying to access functions will fail as the path of our node might be invalid
StorageBase.setsByID(dataID)
Returns:all object sets stored under the given dataID
StorageBase.storageNode()
Returns:Node actually being used as storage
StorageBase.storagePlug(dataID, plugType=None, autoCreate=False)
see storagePlug module level function
StorageBase.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

Epydoc: mrv.maya.nt.storage.StorageNode

class mrv.maya.nt.storage.StorageNode(*args)

Bases: mrv.maya.nt.DependNode, mrv.maya.nt.storage.StorageBase

This node can be used as pythonic and easy-to-access value container - it could be connected to your node, and queried for values actually being queried on your node. As value container, it can easily be replaced by another one, or keep different sets of information

Note:the storage node can only use generic attributes and recover them properly during scene reload if the configuration of the generic attributes have been setup properly - they are unique only per node type, not per instance of the node type. Thus it is recommened to use the storage node attribute base on your own custom type that setsup the generic attributes as it requires during plugin load
class PyPickleValue(valueplug, pythondata)

Bases: object

Wrapper object prividing native access to the wrapped python pickle object and to the corresponding value plug, providing utlity methods for easier handling

isReferenced()
Returns:True if the data is from a referenced plug
StorageNode.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
classmethod StorageNode.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
StorageNode.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
StorageNode.allocateFlag()
StorageNode.apiObject()
Returns:the MObject attached to this Node
StorageNode.apiType()
Returns:the MFn Type id of the wrapped object
StorageNode.attributePrefix()
Returns:our attribute prefix
StorageNode.basename()
Returns:name of this instance
Note:it is mainly for compatability with dagNodes which need this method in order to return the name of their leaf node
StorageNode.children(predicate=<function <lambda> at 0x7f41dd7c2ed8>)
Returns:list of intermediate children of path, [ child1 , child2 ]
Parameter:predicate – return True to include x in result
Note:the child objects returned are supposed to be valid paths, not just relative paths
StorageNode.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

StorageNode.className()
StorageNode.classification()
StorageNode.clearAllData(*args, **kwargs)

see clearAllData module level method :note: use this method if you want to make sure your node

is empty after it has been duplicated (would usually be done in the postContructor
StorageNode.clearData(*args, **kwargs)
Clear all data stored in the given dataID
StorageNode.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
StorageNode.connections()
Returns:MPlugArray of connected plugs
StorageNode.copyFrom(other, *args, **kwargs)

Copy all values from other to ourselves

Parameter:kwargs
  • shallow:
    if True, default False, only a shallow copy will be made. If False, a deep copy will be made
Note:only does so if the attribute and data prefixes actually match (which should be the case if we get here, checking for it anyway
Note:as pickle data always copies by reference to be efficient, we have to explicitly create new data to assure we really copy it
Todo:copy connections to our messages as well, make it an option at least
StorageNode.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
StorageNode.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
StorageNode.createInstance(*args, **kwargs)
Create a new instance with our type
StorageNode.dataIDs()
see module level function with the same name
StorageNode.dataPrefix()
Returns:our data prefix
StorageNode.deallocateAllFlags()
StorageNode.deallocateFlag()
StorageNode.delete(*args, **kwargs)

Delete this node

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
StorageNode.deleteObjectSet(*args, **kwargs)
See the module level method called deleteObjectSet
StorageNode.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 :(

StorageNode.duplicate(*args, **kwargs)

Duplicate our node and return a wrapped version to it

Parameters:
  • name – if given, the newly created node will use the given name
  • kwargs
    • renameOnClash: if Trrue, default True, clashes are prevented by renaming the new node
    • autocreateNamespace: if True, default True, namespaces will be created if mentioned in the name
Note:

the copyTo method may not have not-undoable side-effects to be a proper implementation

Note:

undo could be implemented for dg nodes - but for reasons of consistency, its disabled here - who knows how much it will crap out after a while as duplicate is not undoable (mel command) - it never really worked to undo a mel command from within python, executed using a dgmodifier - unfortunately it does not return any result making it hard to find the newly duplicated object !

StorageNode.findStoragePlug(dataID)
Returns:compound plug with given dataID or None
StorageNode.fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
classmethod StorageNode.getMFnClasses()
Returns:list of all function set classes this node supports, most derived function set comes first
StorageNode.hasFn(mfntype)
Returns:True if our object supports the given function set type
StorageNode.isAlive()
Returns:True if the object exists in memory
Note:objects on the undo queue are alive, but NOT valid
StorageNode.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
StorageNode.isPartOf(other)
Returns:True if self is a part of other, and thus can be found in other
Note:operates on strings only
StorageNode.isRoot()
Returns:True if this path is the root of the DAG
StorageNode.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
StorageNode.isValid()
Returns:True if the object exists in the scene
Note:objects on the undo queue are NOT valid, but alive
StorageNode.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
StorageNode.makePlug(dataID)
see makePlug module level function
StorageNode.masterPlug()
Returns:master plug according to our attributePrefix
StorageNode.object()
Returns:the MObject attached to this Node
StorageNode.objectSet(*args, **kwargs)
see module level objectSet function
StorageNode.parent()
Returns:parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root
StorageNode.parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
StorageNode.partition(dataID)
Returns:partition Node attached to the sets at dataID or None if state is disabled
StorageNode.pythonData(dataID, **kwargs)
Returns:

PyPickleVal object at the given index (it can be modified natively)

Parameters:
  • dataID – id of of the data to retrieve
  • kwargs
    • index:
      element number of the plug to retrieve, or -1 to get a new plug. Plugs will always be created, the given index specifies a logical plug index
    • Additionally all arguments supported by storagePlug
classmethod StorageNode.pythonDataFromPlug(valplug)

Exract the python data using the given plug directly

Parameter:valplug – data value plug containing the plugin data
Returns:PyPickleData object allowing data access
StorageNode.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
StorageNode.removeAttribute(attr)

Remove the given attribute from the node

Parameter:attr – see addAttribute
StorageNode.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
StorageNode.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 !

StorageNode.root()
Returns:the root of the DAG - it has no further parents
StorageNode.setAttributePrefix(prefix)
Change the prefix with which to access to the actual storage data attributes on our node to the given string
StorageNode.setDataPrefix(prefix)
Change the data prefix to the given value string
StorageNode.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
StorageNode.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
StorageNode.setPartition(*args, **kwargs)
see setPartition function on module level
StorageNode.setStorageNode(node)

Set ourselves to use the given storage compatible node

Note:use this if the path of our instance has changed - otherwise trying to access functions will fail as the path of our node might be invalid
StorageNode.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
StorageNode.setsByID(dataID)
Returns:all object sets stored under the given dataID
StorageNode.storageNode()
Returns:Node actually being used as storage
StorageNode.storagePlug(dataID, plugType=None, autoCreate=False)
see storagePlug module level function
StorageNode.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

Epydoc: mrv.maya.nt.storage

class mrv.maya.nt.storage.iDuplicatable

Bases: mrv.interface.Interface

Simple interface allowing any class to be properly duplicated

Note:to implement this interface, implement createInstance and copyFrom in your class
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
basename()
Returns:basename of this path, ‘/hello/world’ -> ‘world’
children(predicate=<function <lambda> at 0x7f41dd7c2ed8>)
Returns:list of intermediate children of path, [ child1 , child2 ]
Parameter:predicate – return True to include x in result
Note:the child objects returned are supposed to be valid paths, not just relative paths
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

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
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
duplicate(*args, **kwargs)

Implements a c-style copy constructor by creating a new instance of self and applying the copyFrom methods from base to all classes implementing the copyfrom method. Thus we will call the method directly on the class

Parameters:
  • args – passed to copyFrom and createInstance method to give additional directions
  • kwargs – see param args
fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
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
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
parent()
Returns:parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root
parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
root()
Returns:the root of the DAG - it has no further parents
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

Table Of Contents

Previous topic

mrv.maya.nt.util

Next topic

mrv.maya.nt.geometry

This Page