Package mrv :: Package maya :: Package nt :: Module apipatch :: Class MPlug
[hide private]
[frames] | no frames]

Class MPlug

source code

OpenMaya.MPlug --+
                 |
                MPlug

Patch applying mrv specific functionality to the MPlug. These methods will be available through methods with the 'm' prefix.

Other methods are overridden to allow more pythonic usage of the MPlug class if and only if it is not specific to mrv.

Additionally it provides aliases for all MPlug methods that are getters, but don't start with a 'get'.


Note: Theoretically the MPlug would satisfy the 'iDagItem' interface, but due to the method prefixes, it could not work here as it calls un-prefixed methods only.

Instance Methods [hide private]
 
__getattribute__(self, attr)
Get attribute for MPlug which will raise if a setX method is used.
source code
    Overridden Methods
 
length(self)
Returns: number of physical elements in the array, but only if they are not connected.
source code
 
__iter__(self)
Returns: iterator object
source code
 
__repr__(self)
Returns: our class representation
source code
 
__eq__(self, other)
Compare plugs,handle elements correctly
source code
 
__ne__(self, other) source code
    Plug Hierarchy Query
 
mparent(self)
Returns: parent of this plug or None
source code
 
mchildren(self, predicate=lambda x: True)
Returns: list of intermediate child plugs, [ plug1 , plug2 ]
source code
 
mchildByName(self, childname)
Returns: MPlug with the given childname
source code
 
msubPlugs(self, predicate=lambda x: True)
Returns: list of intermediate sub-plugs that are either child plugs or element plugs.
source code
    Attributes ( Edit )
 
_mhandleAttrSet(self, state, getfunc, setfunc)
Generic attribute handling
source code
 
msetLocked(self, state)
If True, the plug's value may not be changed anymore
source code
 
msetKeyable(self, state)
if True, the plug may be set using animation curves
source code
 
msetCaching(self, state)
if True, the plug's value will be cached, preventing unnecessary computations
source code
 
msetChannelBox(self, state)
if True, the plug will be visible in the channelbox, even though it might not be keyable or viceversa
source code
    Connections ( Edit )
 
mconnectTo(self, destplug, force=True)
Connect this plug to the right hand side plug
source code
 
mconnectToArray(self, arrayplug, force=True, exclusive_connection=False)
Connect self an element of the given arrayplug.
source code
 
mdisconnect(self)
Completely disconnect all inputs and outputs of this plug.
source code
 
mdisconnectInput(self)
Disconnect the input connection if one exists
source code
 
mdisconnectOutputs(self)
Disconnect all outgoing connections if they exist
source code
 
mdisconnectFrom(self, other)
Disconnect this plug from other plug if they are connected
source code
 
mdisconnectNode(self, other)
Disconnect this plug from the given node if they are connected
source code
    Connections ( Query )
 
misConnectedTo(self, destplug)
Returns: True if this plug is connected to destination plug ( in that order )
source code
 
moutputs(self)
Returns: MPlugArray with all plugs having this plug as source
source code
 
moutput(self)
Returns: first plug that has this plug as source of a connection, or null plug if no such plug exists.
source code
 
minput(self)
Returns: plug being the source of a connection to this plug or a null plug if no such plug exists
source code
 
minputs(self)
Special handler returning the input plugs of array elements
source code
 
miterGraph(self, *args, **kwargs)
Returns: graph iterator with self as root, args and kwargs are passed to it.iterGraph.
source code
 
miterInputGraph(self, *args, **kwargs)
Returns: iterator over the graph starting at this plug in input(upstream) direction.
source code
 
miterOutputGraph(self, *args, **kwargs)
Returns: iterator over the graph starting at this plug in output(downstream) direction.
source code
 
mconnections(self)
Returns: tuple with input and outputs ( inputPlug, outputPlugs )
source code
    Affects Query
 
mdependencyInfo(self, by=False)
Returns: list of plugs on this node that this plug affects or is being affected by
source code
 
maffects(self)
Returns: list of plugs affected by this one
source code
 
maffected(self)
Returns: list of plugs affecting this one
source code
    General Query
 
mnextLogicalIndex(self)
Returns: index of logical indexed plug that does not yet exist
source code
 
mnextLogicalPlug(self)
Returns: plug at newly created logical index
source code
 
mwrappedAttribute(self)
Returns: Attribute instance of our underlying attribute
source code
 
mwrappedNode(self)
Returns: wrapped Node of the plugs node
source code
 
masData(self, *args, **kwargs)
Returns: our data Mobject wrapped in base.Data
source code
 
mfullyQualifiedName(self)
Returns: string returning the absolute and fully qualified name of the plug.
source code
    Name Remapping
 
mict(self, destplug)
Returns: True if this plug is connected to destination plug ( in that order )
source code
 
mdc(self, other)
Disconnect this plug from other plug if they are connected
source code
 
mwn(self)
Returns: wrapped Node of the plugs node
source code
 
mwa(self)
Returns: Attribute instance of our underlying attribute
source code
Class Methods [hide private]
    Connections ( Edit )
 
mconnectMultiToMulti(self, iter_source_destination, force=False)
Connect multiple source plugs to the same amount of detsination plugs.
source code
Static Methods [hide private]
    Connections ( Query )
 
mhaveConnection(lhsplug, rhsplug)
Returns: True if lhsplug and rhs plug are connected - the direction does not matter
source code
Class Variables [hide private]
  pa = api.MPlugArray()
    Overridden Methods
  __str__ = api.MPlug.name
    Set Data with Undo
  msetBool = _mplug_createUndoSetFunc("Bool")
  msetChar = _mplug_createUndoSetFunc("Char")
  msetShort = _mplug_createUndoSetFunc("Short")
  msetInt = _mplug_createUndoSetFunc("Int")
  msetFloat = _mplug_createUndoSetFunc("Float")
  msetDouble = _mplug_createUndoSetFunc("Double")
  msetString = _mplug_createUndoSetFunc("String")
  msetMAngle = _mplug_createUndoSetFunc("MAngle")
  msetMDistance = _mplug_createUndoSetFunc("MDistance")
  msetMTime = _mplug_createUndoSetFunc("MTime")
  msetMObject = _mplug_createUndoSetFunc("MObject")
    Name Remapping
  mctf = lambda self, other:
  mct = lambda self, other:
  mhc = lambda lhs, rhs:
Method Details [hide private]

length(self)

source code 
Returns:
number of physical elements in the array, but only if they are not connected. If in doubt, run evaluateNumElements beforehand

Note: cannot use __len__ as it would break printing of pymel

__iter__(self)

source code 
Returns:
iterator object

__repr__(self)
(Representation operator)

source code 
Returns:
our class representation

mparent(self)

source code 
Returns:
parent of this plug or None

Note: for array plugs, this is the array, for child plugs the actual parent

mchildren(self, predicate=lambda x: True)

source code 
Parameters:
  • predicate - return True to include x in result
Returns:
list of intermediate child plugs, [ plug1 , plug2 ]

mchildByName(self, childname)

source code 
Returns:
MPlug with the given childname
Raises:
  • AttributeError - if no child plug of the appropriate name could be found
  • TypeError - self is not a compound plug

msubPlugs(self, predicate=lambda x: True)

source code 
Parameters:
  • predicate - return True to include x in result
Returns:
list of intermediate sub-plugs that are either child plugs or element plugs. Returned list will be empty for leaf-level plugs

Note: use this function recursively for easy deep traversal of all combinations of array and compound plugs

msetLocked(self, state)

source code 
If True, the plug's value may not be changed anymore
Decorators:
  • @undoable

msetKeyable(self, state)

source code 
if True, the plug may be set using animation curves
Decorators:
  • @undoable

msetCaching(self, state)

source code 
if True, the plug's value will be cached, preventing unnecessary computations
Decorators:
  • @undoable

msetChannelBox(self, state)

source code 
if True, the plug will be visible in the channelbox, even though it might not be keyable or viceversa
Decorators:
  • @undoable

mconnectMultiToMulti(self, iter_source_destination, force=False)
Class Method

source code 
Connect multiple source plugs to the same amount of detsination plugs.
Parameters:
  • iter_source_destination - Iterator yielding pairs of source and destination plugs to connect
  • force - If True, existing input connections on the destination side will be broken automatically. Otherwise the whole operation will fail if one connection could not be made.
Decorators:
  • @undoable
Notes:
  • This method provides the most efficient way to connect a large known amount of plugs to each other
  • Both iterators need to yield the same total amount of plugs
  • In the current implementation, performance will be hurt if force is specified as each destination has to be checked for a connection in advance

mconnectTo(self, destplug, force=True)

source code 
Connect this plug to the right hand side plug
Parameters:
  • destplug - the plug to which to connect this plug to.
  • force - if True, the connection will be created even if another connection has to be broken to achieve that. If False, the connection will fail if destplug is already connected to another plug
Returns:
destplug allowing chained connections a.connectTo(b).connectTo(c)
Decorators:
  • @undoable
Raises:
  • RuntimeError - If destination is already connected and force = False

mconnectToArray(self, arrayplug, force=True, exclusive_connection=False)

source code 
Connect self an element of the given arrayplug.
Parameters:
  • arrayplug - the array plug to which you want to connect to
  • force - if True, the connection will be created even if another connection has to be broken to achieve that.
  • exclusive_connection - if True and destplug is an array, the plug will only be connected to an array element if it is not yet connected
Returns:
newly created element plug or the existing one
Decorators:
  • @undoable

mdisconnect(self)

source code 
Completely disconnect all inputs and outputs of this plug. The plug will not be connected anymore.
Returns:
self, allowing chained commands
Decorators:
  • @undoable

mdisconnectInput(self)

source code 
Disconnect the input connection if one exists
Returns:
self, allowing chained commands
Decorators:
  • @undoable

mdisconnectOutputs(self)

source code 
Disconnect all outgoing connections if they exist
Returns:
self, allowing chained commands
Decorators:
  • @undoable

mdisconnectFrom(self, other)

source code 
Disconnect this plug from other plug if they are connected
Parameters:
  • other - MPlug that will be disconnected from this plug
Returns:
other plug allowing to chain disconnections
Decorators:
  • @undoable

mdisconnectNode(self, other)

source code 
Disconnect this plug from the given node if they are connected
Parameters:
  • other - Node that will be completely disconnected from this plug
Decorators:
  • @undoable

mhaveConnection(lhsplug, rhsplug)
Static Method

source code 
Returns:
True if lhsplug and rhs plug are connected - the direction does not matter

Note: equals lhsplug & rhsplug

misConnectedTo(self, destplug)

source code 
Returns:
True if this plug is connected to destination plug ( in that order )
Notes:
  • return true for self.misConnectedTo(destplug) but false for destplug.misConnectedTo(self)
  • use the mhaveConnection method whether both plugs have a connection no matter which direction
  • use misConnected to find out whether this plug is connected at all

moutputs(self)

source code 
Returns:
MPlugArray with all plugs having this plug as source

To Do: should the method be smarter and deal nicer with complex array or compound plugs ?

moutput(self)

source code 
Returns:
first plug that has this plug as source of a connection, or null plug if no such plug exists.

Note: convenience method

minput(self)

source code 
Returns:
plug being the source of a connection to this plug or a null plug if no such plug exists

minputs(self)

source code 
Special handler returning the input plugs of array elements
Returns:
list of plugs connected to the elements of this arrayplug

Note: if self is not an array, a list with 1 or 0 plugs will be returned

miterGraph(self, *args, **kwargs)

source code 
Returns:
graph iterator with self as root, args and kwargs are passed to it.iterGraph. Plugs are returned by default, but this can be specified explicitly using the plug=True kwarg

miterInputGraph(self, *args, **kwargs)

source code 
Returns:
iterator over the graph starting at this plug in input(upstream) direction. Plugs will be returned by default

Note: see it.iterGraph for valid args and kwargs

miterOutputGraph(self, *args, **kwargs)

source code 
Returns:
iterator over the graph starting at this plug in output(downstream) direction. Plugs will be returned by default

Note: see it.iterGraph for valid args and kwargs

mconnections(self)

source code 
Returns:
tuple with input and outputs ( inputPlug, outputPlugs )

mdependencyInfo(self, by=False)

source code 
Parameters:
  • by - if false, affected attributplugs will be returned, otherwise the attributeplugs affecting this one
Returns:
list of plugs on this node that this plug affects or is being affected by
Notes:
  • you can also use the base.DependNode.dependencyInfo method on the node itself if plugs are not required - this will also be faster
  • have to use MEL :(

maffects(self)

source code 
Returns:
list of plugs affected by this one

maffected(self)

source code 
Returns:
list of plugs affecting this one

mnextLogicalIndex(self)

source code 
Returns:
index of logical indexed plug that does not yet exist
Notes:
  • as this method does a thorough search, it is relatively slow compared to a simple numPlugs + 1 algorithm
  • only makes sense for array plugs

mnextLogicalPlug(self)

source code 
Returns:
plug at newly created logical index

Note: only valid for array plugs

mwrappedAttribute(self)

source code 
Returns:
Attribute instance of our underlying attribute

mwrappedNode(self)

source code 
Returns:
wrapped Node of the plugs node

Note: instance information gets lost this way, the respective instance can be re-retrieved using the instance information on this instanced attribute, if this is an instanced attribute

masData(self, *args, **kwargs)

source code 
Returns:
our data Mobject wrapped in base.Data

Note: args and kwagrs have to be provided as MDGContext.fsNormal does not exist in maya 8.5, so we have to hide that fact.

mfullyQualifiedName(self)

source code 
Returns:
string returning the absolute and fully qualified name of the plug. It might take longer to evaluate but is safe to use if you want to convert the resulting string back to the actual plug

mict(self, destplug)

source code 
Returns:
True if this plug is connected to destination plug ( in that order )
Notes:
  • return true for self.misConnectedTo(destplug) but false for destplug.misConnectedTo(self)
  • use the mhaveConnection method whether both plugs have a connection no matter which direction
  • use misConnected to find out whether this plug is connected at all

mdc(self, other)

source code 
Disconnect this plug from other plug if they are connected
Parameters:
  • other - MPlug that will be disconnected from this plug
Returns:
other plug allowing to chain disconnections
Decorators:
  • @undoable

mwn(self)

source code 
Returns:
wrapped Node of the plugs node

Note: instance information gets lost this way, the respective instance can be re-retrieved using the instance information on this instanced attribute, if this is an instanced attribute

mwa(self)

source code 
Returns:
Attribute instance of our underlying attribute

__getattribute__(self, attr)

source code 
Get attribute for MPlug which will raise if a setX method is used. This could cause undo bugs that you'd better catch before they hit the user