# MSelectionList

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

## Base Class

None.

## Constants

Name | Type | Description
--- | --- | ---
Merge Strategies
kMergeNormal | int | If the object is not already on the list, add it.
kXORWithList | int | If the object is already on the list, remove it, otherwise add it.
kRemoveFromList | int | Remove the object from the list.

## Static Methods

None.

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

## Virtual Methods

None.

## Object Methods

Signature | Parameters | Returns | Description
--- | --- | --- | ---
Available in Maya 2012 Gold:
add(pattern, searchChildNamespaces=False) | pattern - string searchChildNamespaces - bool | Reference to self. | Adds to the list any nodes, DAG paths, components or plugs which match the given pattern.
getDagPath(index) | index - int | 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. 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.
getDependNode(index) | index - int | MObject | 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.
getPlug(index) | index - int | 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.
Available in Maya 2012 HotFix 1:
add(item, mergeWithExisting=True) | item - MObject, MDagPath, MPlug or tuple of (MDagPath, MObject). mergeWithExisting - bool | Reference to self. | 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.
clear() |  | Reference to self. | Empties the selection list.
copy(src) | src - MSelectionList | Reference to self. | Replaces the contents of the selection list with a copy of those from src.
getComponent(index) | index - int | (MDagPath, MObject) | 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.
getSelectionStrings(index=None) | index - int | tuple of strings | 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.
hasItem(item) | item - MObject, MDagPath, MPlug or tuple of (MDagPath, MObject). | 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.
hasItemPartly(dagPath, component) | dagPath - MDagPath component - MObject | 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.
isEmpty() |  | bool | Returns True if the selection list is empty.
length() |  | int | Returns the number of items on the selection list.
merge(other, strategy=kMergeNormal) | other - MSelectionList). strategy - Merge Strategy constant | Reference to self | Merges the items from another selection list in with those already on the list, using the given strategy.
merge(dagPath, component, strategy=kMergeNormal) | dagPath - MDagPath component - MObject strategy - Merge Strategy constant | Reference to self | Merges the specified component in with those already on the list, using the given strategy.
remove(index) | index - int | Reference to self | Removes the index'th item from the list. Raises IndexError if the index is out of range.
replace(index, newItem) | index - int newItem - MObject, MDagPath, MPlug or tuple of (MDagPath, MObject). | Reference to self | 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.
toggle(dagPath, component) | dagPath - MDagPath component - MObject | Reference to self | Removes from the list those elements of the given component which are already on it and adds those which are not.

## Object Attributes

None.

## Sequence Support

None.

## Number Support

None.

## Comparison Support

None.

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

© 2011 Autodesk, Inc. All rights reserved.