#include <MSelectionList.h>
A list of MObjects.
This class implements a list of MObjects.
The global selection list is a special case where the objects on the list are also active objects in Maya.
Besides the usual list methods, this class also provides an add method which retrieves objects from Maya, such as dependency nodes, by name.
Public Types | |
enum | MergeStrategy { kMergeNormal =0, kXORWithList, kRemoveFromList } |
Specifies how to merge objects with those already in the list. More... | |
Public Member Functions | |
MSelectionList () | |
Class constructor. More... | |
MSelectionList (const MSelectionList &src) | |
Copy constructor. More... | |
virtual | ~MSelectionList () |
Class destructor. More... | |
MStatus | clear () |
This method empties the selection list. More... | |
bool | isEmpty (MStatus *ReturnStatus=NULL) const |
Specifies whether or not the selection list contains any items. More... | |
unsigned int | length (MStatus *ReturnStatus=NULL) const |
This method returns the number of selection items in the list. More... | |
MStatus | getDependNode (unsigned int index, MObject &depNode) const |
Get a handle for the dependency node of the given element of the selection list. More... | |
MStatus | getDagPath (unsigned int index, MDagPath &dagPath, MObject &component=MObject::kNullObj) const |
Get the dag path and component (may be NULL) of the given element of the selection list. More... | |
MStatus | getPlug (unsigned int index, MPlug &plug) const |
Get the plug at the specified index of the selection list. More... | |
MStatus | add (const MObject &object, const bool mergeWithExisting=false) |
Add the specified DG node to the end of the selection list. More... | |
MStatus | add (const MDagPath &object, const MObject &component=MObject::kNullObj, const bool mergeWithExisting=false) |
Add the specified DG node to the end of the selection list. More... | |
MStatus | add (const MString &matchString, const bool searchChildNamespacesToo=false) |
Add the specified object(s) to the selection list. More... | |
MStatus | add (const MPlug &plug, const bool mergeWithExisting=false) |
Add the specified plug to the end of the selection list. More... | |
MStatus | add (const MUuid &uuid, bool mergeWithExisting=false) |
Add nodes matching the UUID to the selection list. More... | |
MStatus | remove (unsigned int index) |
Removes the item at the given index from the list. More... | |
MStatus | replace (unsigned int index, const MObject &item) |
Remove the item at the given index in the list and replace it with the given object. More... | |
MStatus | replace (unsigned int index, const MDagPath &item, const MObject &component=MObject::kNullObj) |
Remove the item at the given index in the list and replace it with the given Dag item (or components). More... | |
MStatus | replace (unsigned int index, const MPlug &plug) |
Remove the item at the given index in the list and replace it with the given plug. More... | |
bool | hasItem (const MObject &item, MStatus *ReturnStatus=NULL) const |
Determines whether or not the given dependency node is in this selection list. More... | |
bool | hasItem (const MDagPath &item, const MObject &component=MObject::kNullObj, MStatus *ReturnStatus=NULL) const |
Determines whether or not the given DAG object is in this selection list. More... | |
bool | hasItem (const MPlug &plug, MStatus *ReturnStatus=NULL) const |
Determines whether or not the given plug is in this selection list. More... | |
bool | hasItemPartly (const MDagPath &item, const MObject &component, MStatus *ReturnStatus=NULL) const |
This method differs from hasItem in that it determines whether or not at least one of the components of the the given DAG object are in this selection list. More... | |
MStatus | toggle (const MDagPath &item, const MObject &component=MObject::kNullObj) |
Removes those components of the given selection item which are on the selection list, and adds those parts which are not. More... | |
MSelectionList & | operator= (const MSelectionList &other) |
Assignment operator. More... | |
MStatus | merge (const MSelectionList &other, const MergeStrategy strategy=kMergeNormal) |
Merge the two selection lists. More... | |
MStatus | merge (const MDagPath &object, const MObject &component=MObject::kNullObj, const MergeStrategy strategy=kMergeNormal) |
Merge the given DAG object into the selection list. More... | |
MStatus | intersect (const MSelectionList &other, bool expandToLeaves=false) |
Modify this list to contain the intersection of itself and the given list. More... | |
MStatus | getSelectionStrings (MStringArray &array) const |
Gets the string representations of the items in the selection list. More... | |
MStatus | getSelectionStrings (unsigned int index, MStringArray &array) const |
Gets the string representation of the given item in the selection list. More... | |
Static Public Member Functions | |
static const char * | className () |
Returns the name of this class. More... | |
enum MergeStrategy |
OPENMAYA_MAJOR_NAMESPACE_OPEN MSelectionList | ( | ) |
Class constructor.
Creates an empty selection list.
MSelectionList | ( | const MSelectionList & | srcList | ) |
Copy constructor.
This constructor will copy the contents of the given selection list into the newly create selection list.
[in] | srcList | the selection list to be copied. |
|
virtual |
Class destructor.
Removes the selection list.
MStatus clear | ( | ) |
This method empties the selection list.
bool isEmpty | ( | MStatus * | ReturnStatus = NULL | ) | const |
Specifies whether or not the selection list contains any items.
[in] | ReturnStatus | Status flag |
unsigned int length | ( | MStatus * | ReturnStatus = NULL | ) | const |
This method returns the number of selection items in the list.
[out] | ReturnStatus | flag |
Get a handle for the dependency node of the given element of the selection list.
Returns kNullObj and kFailure if selected item does not contain a dependency node.
[in] | index | the items position in the list |
[out] | depNode | storage for the result |
MStatus getDagPath | ( | unsigned int | index, |
MDagPath & | dagPath, | ||
MObject & | component = MObject::kNullObj |
||
) | const |
Get the dag path and component (may be NULL) of the given element of the selection list.
[in] | index | the items position in the list |
[out] | dagPath | storage for the dag path of the item |
[out] | component | storage for a handle for the component. This will be null if there is no component |
Get the plug at the specified index of the selection list.
[in] | index | the items position in the list |
[out] | plug | storage for the result |
Add the specified DG node to the end of the selection list.
[in] | object | The object to add |
[in] | mergeWithExisting | This parameter determines what to do if the given item is already present in the list: If true, the given item is unconditionally added to the end of the list without affecting the pre-existing item. If false, the pre-existing item is moved from its current position to the end of the list. |
MStatus add | ( | const MDagPath & | object, |
const MObject & | component = MObject::kNullObj , |
||
const bool | mergeWithExisting = false |
||
) |
Add the specified DG node to the end of the selection list.
[in] | object | The Dag Object to add |
[in] | component | components of the object |
[in] | mergeWithExisting | This parameter determines what to do if the given item is already present in the list: If true, the given item is unconditionally added to the end of the list without affecting the pre-existing item. If false, the pre-existing item is moved from its current position to the end of the list. In addition, if the pre-existing item already had components specified, the components from the given item are merged into those of the pre-existing item. |
Add the specified object(s) to the selection list.
There is an option to search all child namespaces. The object name should be specified in the same way it would be in the MEL language. It is possible to use wildcard characters, so multiple objects may be added in one method call.
NOTE: the actual namespace being searched is important. In relativeNames mode (see the method MNamespace::relativeNames), the search starts in the current namespace but with relativeNames mode off, the search starts with the root namespace.
[in] | matchString | object match string |
[in] | searchChildNamespacesToo | optional parameter to specify that child namespaces will also be searched. A value of true enables child namespace searching; a value of false (the default) only searches within the namespace. See the above description for details on which namespace gets searched. |
Add the specified plug to the end of the selection list.
[in] | plug | the plug to add |
[in] | mergeWithExisting | This parameter determines what to do if the given item is already present in the list: If true, the given item is unconditionally added to the end of the list without affecting the pre-existing item. If false, the pre-existing item is moved from its current position to the end of the list. |
Add nodes matching the UUID to the selection list.
[in] | uuid | the UUID with which to look up nodes |
[in] | mergeWithExisting | merge new items with existing ones, or add unconditionally to end of list. |
MStatus remove | ( | unsigned int | index | ) |
Removes the item at the given index from the list.
[in] | index | The index of the item to be removed |
Remove the item at the given index in the list and replace it with the given object.
The given index must not be greater than the current number of items on the list.
[in] | item | A pointer to the replacement object |
[in] | index | The index of the item to remove from the list |
MStatus replace | ( | unsigned int | index, |
const MDagPath & | item, | ||
const MObject & | component = MObject::kNullObj |
||
) |
Remove the item at the given index in the list and replace it with the given Dag item (or components).
The given index must not be greater than the current number of items on the list.
[in] | item | the new dag object to place into the list |
[in] | component | the components of item to add |
[in] | index | The index of the item to remove from the list |
Remove the item at the given index in the list and replace it with the given plug.
The given index must not be greater than the current number of items on the list.
[in] | plug | The replacement plug |
[in] | index | The index of the item to remove from the list |
Determines whether or not the given dependency node is in this selection list.
Note that if the selection list contains a DAG node, the overloaded version of this method that takes an MDagPath must be used. A dag path will not compare identically to a DG node, even if they both refer to the same node.
[in] | item | The item to check for |
[out] | ReturnStatus | Status flag |
bool hasItem | ( | const MDagPath & | item, |
const MObject & | component = MObject::kNullObj , |
||
MStatus * | ReturnStatus = NULL |
||
) | const |
Determines whether or not the given DAG object is in this selection list.
If the component argument is non-null, then this method will only return true of all the components of the given DAG object are on the selection list.
[in] | item | the DAG object to check for |
[in] | component | the components of item to check for |
[out] | ReturnStatus | Status flag |
Determines whether or not the given plug is in this selection list.
[in] | plug | The plug to check for |
[out] | ReturnStatus | Status flag |
bool hasItemPartly | ( | const MDagPath & | item, |
const MObject & | component, | ||
MStatus * | ReturnStatus = NULL |
||
) | const |
This method differs from hasItem in that it determines whether or not at least one of the components of the the given DAG object are in this selection list.
This method is only applicable when multiple components are provided.
[in] | item | the DAG object to check for |
[in] | component | the components of item to check for |
[out] | ReturnStatus | Status flag |
MStatus toggle | ( | const MDagPath & | item, |
const MObject & | component = MObject::kNullObj |
||
) |
Removes those components of the given selection item which are on the selection list, and adds those parts which are not.
This method does nothing if no components are provided.
[in] | item | Dag object to be toggled |
[in] | component | components of the object |
MSelectionList & operator= | ( | const MSelectionList & | other | ) |
Assignment operator.
[in] | other | the selection list to be copied |
MStatus merge | ( | const MSelectionList & | other, |
const MergeStrategy | strategy = kMergeNormal |
||
) |
Merge the two selection lists.
[in] | other | the selection list to be merged. |
[in] | strategy | the merging strategy. It can be one of the the following: |
MStatus merge | ( | const MDagPath & | item, |
const MObject & | component = MObject::kNullObj , |
||
const MergeStrategy | strategy = kMergeNormal |
||
) |
Merge the given DAG object into the selection list.
[in] | item | the dependency node to be merged. |
[in] | component | components of the Dag object to add |
[in] | strategy | the merging strategy. It can be one of the following: |
MStatus intersect | ( | const MSelectionList & | other, |
bool | expandToLeaves = false |
||
) |
Modify this list to contain the intersection of itself and the given list.
[in] | other | the selection list to be intersected. |
[in] | expandToLeaves | If expandToLeaves is true, the two lists will be copied and grown to include leaf nodes before performing the intersection. |
MStatus getSelectionStrings | ( | MStringArray & | array | ) | const |
Gets the string representations of the items in the selection list.
The strings will be in the format used by the scripting language.
[out] | array | storage for the returned strings |
MStatus getSelectionStrings | ( | unsigned int | index, |
MStringArray & | array | ||
) | const |
Gets the string representation of the given item in the selection list.
The strings will be in the format used by the scripting language. More than one string will be returned in the case that the item in the selection list has a component that that contains elements that are not contiguous (eg CV's 2 and 8 are selected on a surface).
[in] | index | index of the element to get |
[out] | array | storage for the returned strings |
|
static |
Returns the name of this class.