Python API 2.0 Reference
OpenMaya.MSelectionList Class Reference
+ Inheritance diagram for OpenMaya.MSelectionList:

Public Member Functions

def __init__ ()
 
def __str__ ()
 
def intersect ()
 
Available in Maya 2012 Gold:
def add ()
 
def getDagPath ()
 
def getDependNode ()
 
def getPlug ()
 
Available in Maya 2012 HotFix 1:
def clear ()
 
def copy ()
 
def getComponent ()
 
def getSelectionStrings ()
 
def hasItem ()
 
def hasItemPartly ()
 
def isEmpty ()
 
def length ()
 
def merge ()
 
def remove ()
 
def replace ()
 
def toggle ()
 

Static Public Member Functions

def __new__ ()
 

Static Public Attributes

Merge Strategies
int kMergeNormal = 0
 
int kRemoveFromList = 2
 
int kXORWithList = 1
 

Detailed Description

A heterogenous list of MObjects, MPlugs and MDagPaths.

__init__()
Initializes a new, empty MSelectionList object.

__init__(MSelectionList other)
Initializes a new MSelectionList object containing the same
items as another list.

MSelectionList is currently a stub which only implements a small portion of the class's total functionality.

Constructors

Signature Parameters Description
MSelectionList()  

Default constructor. Returns a new, empty MSelectionList object.

MSelectionList(src) src - MSelectionList

Copy constructor. Returns a new MSelectionList with the same contents as src.

str() Support

Available in Maya 2012 HotFix 1:

Returns a string showing the result of the getSelectionStrings() method as a tuple. E.g. ('time1', 'persp.tx', 'meshShape1.f[3:5]')

repr() Support

Default.

 


Constructor & Destructor Documentation

def OpenMaya.MSelectionList.__init__ ( )
Initialize self.  See help(type(self)) for accurate signature.

Member Function Documentation

def OpenMaya.MSelectionList.__new__ ( )
static
Create and return a new object.  See help(type) for accurate signature.
def OpenMaya.MSelectionList.__str__ ( )
Return str(self).
OpenMaya.MSelectionList.add ( )
add(pattern, searchChildNamespaces=False) -> self
add(item, mergeWithExisting=True) -> self


The first version adds to the list any nodes, DAG paths, components
or plugs which match the given the pattern string.

The second version adds the specific item to the list, where the
item can be a plug (MPlug), a node (MObject), a DAG path (MDagPath)
or a component (tuple of (MDagPath, MObject) ).
Signature: add(pattern, searchChildNamespaces=False)
Parameters: pattern - string

searchChildNamespaces - bool
Returns: Reference to self.
Description: Adds to the list any nodes, DAG paths, components or plugs which match the given pattern.
Signature: add(item, mergeWithExisting=True)
Parameters: item - MObject, MDagPath, MPlug or tuple of (MDagPath, MObject).

mergeWithExisting - bool
Returns: Reference to self.
Description:

Adds a node, DAG path, plug or component to the end of the selection list. A component is passed as a tuple containing the MDagPath of the DAG node and an MObject containing the component.

If mergeWithExisting is True and the item is already on the list then those existing instances of the item will be removed, leaving just the newly added instance at the end of the list. For components this applies at the component element level, meaning that any overlapping elements will be removed from the existing components. If mergeWithExisting is False then the new item is added to the end of the list without affecting any existing instances of the item already on the list.

OpenMaya.MSelectionList.clear ( )
clear() -> self

Empties the selection list.
Signature: clear()
Parameters:
Returns: Reference to self.
Description: Empties the selection list.
OpenMaya.MSelectionList.copy ( )
copy(src) -> self

Replaces the contents of the selection list with a copy of those from src (MSelectionList).
Signature: copy(src)
Parameters: src - MSelectionList
Returns: Reference to self.
Description: Replaces the contents of the selection list with a copy of those from src.
OpenMaya.MSelectionList.getComponent ( )
getComponent(index) -> (MDagPath, MObject)

Returns the index'th item of the list as a component, represented by
a tuple containing an MDagPath and an MObject. If the item is just a
DAG path without a component then MObject.kNullObj will be returned
in the second element of the tuple. Raises TypeError if the item is
neither a DAG path nor a component. Raises IndexError if index is
out of range.
Signature: getComponent(index)
Parameters: index - int
Returns: (MDagPath, MObject)
Description: Returns the index'th item of the list as a component, represented by a tuple containing the item's MDagPath and an MObject containing its component. If the item is just a DAG path without a component then MObject.kNullObj will be returned in the second element of the tuple. Raises TypeError if the item is neither a DAG path nor a component. Raises IndexError if index is out of range.
OpenMaya.MSelectionList.getDagPath ( )
getDagPath(index) -> MDagPath

Returns the DAG path associated with the index'th item of the list.
Raises TypeError if the item is neither a DAG path nor a component.
Raises IndexError if index is out of range.
Signature: getDagPath(index)
Parameters: index - int
Returns: MDagPath
Description: Returns the DAG path associated with the index'th item of the list. Raises TypeError if the item is neither a DAG path nor a component. Raises IndexError if index is out of range.

Release Note: In Maya 2012 Gold this method returned a tuple containing both the DAG path and the component. In Maya 2012 HotFix 1 that functionality is supplied by the getComponent() method and this method returns only the DAG path. Existing code which uses this method will have to be modified accordingly.
OpenMaya.MSelectionList.getDependNode ( )
getDependNode(index) -> MObject

Returns the node associated with the index'th item, whether it be a
dependency node, DAG path, component or plug.
Raises kFailure if there is no dependency node associated with the current item.
Raises IndexError if index is out of range.
Signature: getDependNode(index)
Parameters: index - int
Returns: MObject
Description: Returns the node associated with the index'the item, whether it be a dependency node, DAG path, component or plug. Raises IndexError if index is out of range.
OpenMaya.MSelectionList.getPlug ( )
getPlug(index) -> MPluggetPlug(index, convertComponents) -> MPlug

Returns the index'th item of the list as a plug. Raises TypeError if
the item is not a plug. Raises IndexError if index is out of range.
If convertComponents is True then components in the selection list that have a corresponding plug will return that instead.
Note: This only works if the component selection can be converted into a single plug - single component or all components selected.
Signature: getPlug(index)
Parameters: index - int
Returns: MPlug
Description: Returns the index'th item of the list as a plug. Raises TypeError if the item is not a plug. Raises IndexError if index is out of range.
OpenMaya.MSelectionList.getSelectionStrings ( )
getSelectionStrings(index=None) -> (string, string, ...)

Returns a tuple containing the string representation of the
specified item. For nodes, DAG paths, plugs and contiguous
components the tuple will only contain a single string, but for non-
contiguous components there will be a separate string for each
distinct block of contiguous elements. If index is not specified
then the string representations of all the items in the selection
list are returned. Raises IndexError if index is out of bounds.
Signature: getSelectionStrings(index=None)
Parameters: index - int
Returns: tuple of strings
Description: Returns a tuple containing the string representation of the specified item. For nodes, DAG paths, plugs and contiguous components the tuple will only contain a single string, but for non-contiguous components there will be a separate string for each distinct block of contiguous elements. If index is not specified then the string representations of all the items in the selection list are returned. Raises IndexError if index is out of bounds.
OpenMaya.MSelectionList.hasItem ( )
hasItem(item) -> bool

Returns True if the given item is on the selection list. For a
component this means that all of the elements of the component must
be on the list. A component is passed as a tuple containing the
MDagPath of the DAG node and an MObject containing the component.
Signature: hasItem(item)
Parameters: item - MObject, MDagPath, MPlug or tuple of (MDagPath, MObject).
Returns: bool
Description: Returns True if the given item is on the selection list. For a component this means that all of the elements of the component must be on the list. A component is passed as a tuple containing the MDagPath of the DAG node and an MObject containing the component.
OpenMaya.MSelectionList.hasItemPartly ( )
hasItemPartly(dagPath, component) -> bool

Returns True if at least one of the component's elements is on the
selection list. Raises TypeError if dagPath is invalid or component
does not contain a component.
Signature: hasItemPartly(dagPath, component)
Parameters: dagPath - MDagPath

component - MObject
Returns: bool
Description: Returns True if at least one of the component's elements is on the selection list. Raises TypeError if dagPath is invalid or component does not contain a component.
def OpenMaya.MSelectionList.intersect ( )
intersect(other, expandToLeaves=False) -> self

Modify this list to contain the intersection of itself and the given list.
OpenMaya.MSelectionList.isEmpty ( )
isEmpty() -> bool

Returns True if the selection list is empty.
Signature: isEmpty()
Parameters:
Returns: bool
Description: Returns True if the selection list is empty.
OpenMaya.MSelectionList.length ( )
length() -> int

Returns the number of items on the selection list.
Signature: length()
Parameters:
Returns: int
Description: Returns the number of items on the selection list.
OpenMaya.MSelectionList.merge ( )
merge(other, strategy=kMergeNormal) -> self
merge(dagPath, component, strategy=kMergeNormal) -> self

The first version merges the items from another selection list in
with those already on the list, using the given strategy.

The second version merges the specified component with those already
on the list.
Signature: merge(other, strategy=kMergeNormal)
Parameters: other - MSelectionList).

strategy - Merge Strategy constant
Returns: Reference to self
Description: Merges the items from another selection list in with those already on the list, using the given strategy.
Signature: merge(dagPath, component, strategy=kMergeNormal)
Parameters: dagPath - MDagPath

component - MObject<br>
strategy - Merge Strategy constant
Returns: Reference to self
Description: Merges the specified<span> component in with those already on the list, using the given<span> strategy.
OpenMaya.MSelectionList.remove ( )
remove(index) -> self

Removes the index'th item from the list. Raises IndexError if the
index is out of range.
Signature: remove(index)
Parameters: index - int
Returns: Reference to self
Description: Removes the index'th item from the list. Raises IndexError if the index is out of range.
OpenMaya.MSelectionList.replace ( )
replace(index, newItem) -> self

Replaces the index'th item on the list with a new item. A component
is passed as a tuple containing the MDagPath of the DAG node and an
MObject containing the component. Raises IndexError if the index is
out of range.
Signature: replace(index, newItem)
Parameters: index - int

newItem - MObject, MDagPath, MPlug or tuple of (MDagPath, MObject).
Returns: Reference to self
Description: Replaces the index'th item on the list with newItem. A component is passed as a tuple containing the MDagPath of the DAG node and an MObject containing the component. Raises IndexError if the index is out of range.
OpenMaya.MSelectionList.toggle ( )
toggle(dagPath, component) -> self

Removes from the list those elements of the given component which
are already on it and adds those which are not.
Signature: toggle(dagPath, component)
Parameters: dagPath - MDagPath

component - MObject
Returns: Reference to self
Description: Removes from the list those elements of the given component which are already on it and adds those which are not.

Member Data Documentation

OpenMaya.MSelectionList.kMergeNormal = 0
static
Name: kMergeNormal
Type: int
Description: If the object is not already on the list, add it.
OpenMaya.MSelectionList.kRemoveFromList = 2
static
Name: kRemoveFromList
Type: int
Description: Remove the object from the list.
OpenMaya.MSelectionList.kXORWithList = 1
static
Name: kXORWithList
Type: int
Description: If the object is already on the list, remove it, otherwise add it.