C++ API Reference
MItSelectionList Class Reference

Iterate over the items in the selection list. More...

#include <MItSelectionList.h>

Public Types

enum  selItemType { , kDagSelectionItem, kAnimSelectionItem, kDNselectionItem, kPlugSelectionItem }
 Types of items which can appear on a selection list. More...
 

Public Member Functions

bool isDone (MStatus *ReturnStatus=NULL)
 Specifies whether or not there is anything more to iterator over. More...
 
MStatus next ()
 Advance to the next item. More...
 
MStatus reset ()
 Reset the iterator. More...
 
MStatus getDependNode (MObject &depNode)
 This method retrieves the dependency node of the current selection item. More...
 
MStatus getDagPath (MDagPath &dagPath, MObject &component)
 This method retrieves the dag path and the components of the current selection item. More...
 
MStatus getDagPath (MDagPath &dagPath)
 This method retrieves the dag path of the current selection item. More...
 
MStatus getPlug (MPlug &plug)
 This method retrieves the plug of the current selection item. More...
 
MStatus getStrings (MStringArray &array)
 Get the string representation of the current item in the selection list. More...
 
selItemType itemType (MStatus *ReturnStatus=NULL)
 Returns the current selection item type. More...
 
MStatus setFilter (MFn::Type filter)
 Apply a filter to the iteration. More...
 
bool hasComponents (MStatus *ReturnStatus=NULL) const
 Returns whether or not the current selection item has components. More...
 
 MItSelectionList (const MSelectionList &list, MFn::Type=MFn::kInvalid, MStatus *ReturnStatus=NULL)
 Class constructor. More...
 
virtual ~MItSelectionList ()
 Class destructor. More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 

Detailed Description

Iterate over the items in the selection list.

Class for iterating over the items in an MSelection list. A filter can be specified so that only those items of interest on a selection list can be obtained.

If a filter is specified then the children of DAG selection items will be searched if the selection item does not match the filter. For example, if filter = MFn::kNurbsCurve and a transform is selected then the underlying shape for the transform will be in the iteration if it is a nurbs curve.

Example: (of a simple traversal)

MSelectionList activeList;
MGlobal::activeSelectionList(activeList);
MItSelectionList iter( activeList );
for ( ; !iter.isDone(); iter.next() )
{
MDagPath item;
MObject component;
iter.getDagPath( item, component );
// do something with it
}

Example: (of a traversal to find all active cameras)

MSelectionList activeList;
MGlobal::activeSelectionList(activeList);
MItSelectionList iter( activeList, MFn::kCamera );
for ( ; !iter.isDone(); iter.next() )
{
MDagPath camera;
iter.getDagPath( camera );
MFnCamera cameraFn( camera );
// ...
}
Examples:
AbcExport/MayaMeshWriter.cpp, AbcImport/CreateSceneHelper.cpp, animExportUtil/animExportUtil.cpp, apiMeshShape/apiMeshSubSceneOverride.cpp, blindComplexDataCmd/blindComplexDataCmd.cpp, blindDoubleDataCmd/blindDoubleDataCmd.cpp, blindShortDataCmd/blindShortDataCmd.cpp, cleanPerFaceAssignment/cleanPerFaceAssignmentCmd.cpp, closestPointCmd/closestPointCmd.cpp, componentScaleManip/componentScaleManip.cpp, convertEdgesToFacesCmd/convertEdgesToFacesCmd.cpp, convertVerticesToEdgesCmd/convertVerticesToEdgesCmd.cpp, convertVerticesToFacesCmd/convertVerticesToFacesCmd.cpp, createClipCmd/createClipCmd.cpp, customAttrManip/customAttrManip.cpp, cvExpandCmd/cvExpandCmd.cpp, cvPosCmd/cvPosCmd.cpp, dagPoseInfoCmd/dagPoseInfoCmd.cpp, findFileTexturesCmd/findFileTexturesCmd.cpp, fragmentDumper/fragmentDumper.cpp, getAttrAffectsCmd/getAttrAffectsCmd.cpp, helix2Cmd/helix2Cmd.cpp, hwApiTextureTest/hwApiTextureTest.cpp, instancerListCmd/instancerListCmd.cpp, intersectCmd/intersectCmd.cpp, lassoTool/lassoTool.cpp, latticeNoise/latticeNoiseCmd.cpp, lepTranslator/lepTranslator.cpp, lineManip/lineManip.cpp, lineManipContainer/lineManipContainer.cpp, listRichSelectionCmd/listRichSelectionCmd.cpp, lockEvent/lockEvent.cpp, manipOverride/customTriadManip.cpp, manipOverride/manipOverride.cpp, meshOpCmd/meshOpCmd.cpp, motionPathCmd/motionPathCmd.cpp, motionTraceCmd/motionTraceCmd.cpp, moveCurveCVsCmd/moveCurveCVsCmd.cpp, moveManip/moveManip.cpp, moveTool/moveTool.cpp, narrowPolyViewer/narrowPolyViewer.cpp, nodeInfoCmd/nodeInfoCmd.cpp, objExport/objExport.cpp, pointManip/pointManip.cpp, polyRawExporter/polyExporter.cpp, polyX3DExporter/polyExporter.cpp, richMoveCmd/richMoveCmd.cpp, rotateManip/rotateManip.cpp, spiralAnimCurveCmd/spiralAnimCurveCmd.cpp, splitUVCmd/splitUVCmd.cpp, squareScaleManip/squareScaleManip.cpp, squareScaleManipContext/squareScaleManipContext.cpp, surfaceBumpManip/surfaceBumpManip.cpp, surfaceTwistCmd/surfaceTwistCmd.cpp, translateCmd/translateCmd.cpp, viewRenderOverride/viewRenderOverrideOperations.cpp, and whatisCmd/whatisCmd.cpp.

Member Enumeration Documentation

Types of items which can appear on a selection list.

Enumerator
kDagSelectionItem 

DAG node or component.

kAnimSelectionItem 

keyset

kDNselectionItem 

dependency node

kPlugSelectionItem 

plug

Constructor & Destructor Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN MItSelectionList ( const MSelectionList list,
MFn::Type  filter = MFn::kInvalid,
MStatus ReturnStatus = NULL 
)

Class constructor.

Creates a iterator for the given selection list.

NOTE: this class iterates on a copy of the given list and so any changes to the original list will not be reflected upon in this iterator.

Parameters
[in]listThe selection list to iterate over
[in]filterType filter
[out]ReturnStatusStatus code
Status Codes:
  • MS::kSuccess An iterator was successfully set up
  • MS::kInsufficientMemory No memory
  • MS::kFailure Error constructing iterator
~MItSelectionList ( )
virtual

Class destructor.

Removes internal iterator data.

Member Function Documentation

MStatus next ( )

Advance to the next item.

If components are selected then advance to next component.

If a filter is specified then the next item will be one that matches the filter.

Returns
Status code
Status Codes:
  • MS::kSuccess Advance was successfull
  • MS::kFailure Advance was not successfull
Examples:
AbcExport/MayaMeshWriter.cpp, AbcImport/CreateSceneHelper.cpp, cleanPerFaceAssignment/cleanPerFaceAssignmentCmd.cpp, lockEvent/lockEvent.cpp, and moveCurveCVsCmd/moveCurveCVsCmd.cpp.
MStatus reset ( )

Reset the iterator.

If a filter has been specified then the current item will be the first selected item that matches the filter.

Returns
Status code
Status Codes:
  • MS::kSuccess The iterator was successfully reset
  • MS::kFailure Error resetting iterator
Examples:
cleanPerFaceAssignment/cleanPerFaceAssignmentCmd.cpp.
MStatus getDependNode ( MObject depNode)

This method retrieves the dependency node of the current selection item.

Parameters
[out]depNodea pointer the the dependency node to be retrieved Returns kNullObj and kFailure if components are selected or selected item does not contain a dependency node.
Returns
Status code
Status Codes:
  • MS::kSuccess The dependency node was retrieved
  • MS::kFailure Current item does not match filter
Examples:
fragmentDumper/fragmentDumper.cpp, and lockEvent/lockEvent.cpp.
MStatus getDagPath ( MDagPath dagPath,
MObject component 
)

This method retrieves the dag path and the components of the current selection item.

If components are not selected then NULL is assigned to the component pointer.

Parameters
[out]dagPathThe dag path of the current selection item.
[out]componentA pointer to the selected components of the current selection item.
Returns
Status code
Status Codes:
  • MS::kSuccess The dag path and component was retrieved
  • MS::kFailure Current item does not match filter
Examples:
AbcExport/MayaMeshWriter.cpp, AbcImport/CreateSceneHelper.cpp, cleanPerFaceAssignment/cleanPerFaceAssignmentCmd.cpp, fragmentDumper/fragmentDumper.cpp, lockEvent/lockEvent.cpp, and moveCurveCVsCmd/moveCurveCVsCmd.cpp.
MStatus getDagPath ( MDagPath dagPath)

This method retrieves the dag path of the current selection item.

Parameters
[out]dagPathThe dag path of the current selection item.
Returns
Status code
Status Codes:
  • MS::kSuccess The dag path was retrieved
  • MS::kFailure Current item does not match filter
MStatus getPlug ( MPlug plug)

This method retrieves the plug of the current selection item.

Parameters
[out]plugThe plug of the current selection item.
Returns
Status code
Status Codes:
  • MS::kSuccess The plug was retrieved
  • MS::kFailure Current item does not match filter, or there is no current element
MStatus getStrings ( MStringArray array)

Get the string representation of the current item in the selection list.

It is possible that it will require more than one string to represent the item (the item may contain groups of CVs for example), so a string array is used to pass back the results.

Parameters
[out]arrayStorage for the returned array.
Returns
Status code
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure there is no current element
Examples:
lockEvent/lockEvent.cpp.
MItSelectionList::selItemType itemType ( MStatus ReturnStatus = NULL)

Returns the current selection item type.

Parameters
[out]ReturnStatusStatus code
Returns
  • kDagSelectionItem - selection item is in the DAG
  • kAnimSelectionItem - selection item is a keyset
  • kDNselectionItem - selection item is a dependency node
Status Codes:
  • MS::kSuccess The selection item type was successfully returned
  • MS::kFailure Iterator error
MStatus setFilter ( MFn::Type  filter)

Apply a filter to the iteration.

Selection items not matching the filter type will be excluded from the iteration.

Parameters
[in]filterThe MFn::Type that you will be included in the iteration. See MFn.h for possible types.
Returns
Status code
Status Codes:
  • MS::kSuccess The filter was successfully set
  • MS::kFailure The was an error setting the filter
bool hasComponents ( MStatus ReturnStatus = NULL) const

Returns whether or not the current selection item has components.

Parameters
[out]ReturnStatusStatus code
Returns
  • true the current selection item has components
  • false the current selection item does not have components
Status Codes:
  • MS::kSuccess hasComponents successfully returned a result
  • MS::kFailure operation failed
Examples:
AbcExport/MayaMeshWriter.cpp.
const char * className ( )
static

Returns the name of this class.

Returns
The name of this class.

The documentation for this class was generated from the following files: