class MItSelectionList

Jump to documentation

Iterate over the items in the selection list. (OpenMaya) (OpenMaya.py)

public members:

enum selItemType
kUnknownItem
kDagSelectionItem
kAnimSelectionItem
kDNselectionItem
bool isDone ( MStatus * ReturnStatus = NULL )
MStatus next ()
MStatus reset ()
MStatus getDependNode ( MObject &depNode )
MStatus getDagPath ( MDagPath &dagPath, MObject &component )
MStatus getDagPath ( MDagPath &dagPath )
MStatus getStrings ( MStringArray & array )
selItemType itemType ( MStatus * ReturnStatus = NULL )
MStatus setFilter ( MFn::Type filter )
bool hasComponents ( MStatus * ReturnStatus = NULL ) const
MItSelectionList ( const MSelectionList & list, MFn::Type = MFn::kInvalid, MStatus * ReturnStatus = NULL )
virtual ~MItSelectionList ()

Documentation

Class for iterating over the items in an MSelection list.
Description

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();
    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();
    MItSelectionList iter( activeList, MFn::kCamera );

    for ( ; !iter.isDone(); iter.next() )
    {								
        MDagPath camera;			
        MObject component;		
        iter.getDagPath( camera, component );
								
        MFnCamera( item );		
								
        // ...					
   }							

Functions

MItSelectionList:: MItSelectionList ( const MSelectionList & list, MFn::Type filter, MStatus * ReturnStatus )

Description

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.

Arguments

  • list The selection list to iterate over
  • filter Type filter
  • ReturnStatus Status code

Status Codes

  • MS::kSuccess An iterator was successfully set up
  • MS::kInsufficientMemory No memory
  • MS::kFailure Error constructing iterator

MItSelectionList:: ~MItSelectionList ()

Description

Class destructor.
Removes internal iterator data.

bool MItSelectionList:: isDone ( MStatus * ReturnStatus)

Description

Specifies whether or not there is anything more to iterator over.

Arguments

  • ReturnStatus Status code

Return Value

  • true if there is nothing else to iterate over
  • false if there are more items left to iterate over

Status Codes

  • MS::kSuccess Method successfully returned a result
  • MS::kFailure Error, iterator not set up correctly

MStatus MItSelectionList:: reset ()

Description

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

Return Value

  • Status code

Status Codes

  • MS::kSuccess The iterator was successfully reset
  • MS::kFailure Error resetting iterator

MStatus MItSelectionList:: next ()

Description

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.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Advance was successfull
  • MS::kFailure Advance was not successfull

MStatus MItSelectionList:: getDependNode ( MObject &depNode )

Description

This method retrieves the dependency node of the current selection item

Arguments

  • depNode a pointer the the dependency node to be retrieved

Return Value

  • Status code

Status Codes

  • MS::kSuccess The dependency node was retrieved
  • MS::kFailure Current item does not match filter

MStatus MItSelectionList:: getDagPath ( MDagPath & dagPath, MObject &component )

Description

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.

Arguments

  • dagPath The dag path of the current selection item.
  • component A pointer to the selected components of the current selection item.

Return Value

  • Status code

Status Codes

  • MS::kSuccess The dag path and component was retrieved
  • MS::kFailure Current item does not match filter

MStatus MItSelectionList:: getDagPath ( MDagPath & dagPath)

Description

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

Arguments

  • dagPath The dag path of the current selection item.

Return Value

  • Status code

Status Codes

  • MS::kSuccess The dag path was retrieved
  • MS::kFailure Current item does not match filter

MStatus MItSelectionList:: getStrings ( MStringArray & array )

Description

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.

Arguments

  • array Storage for the returned array.

Return Value

  • Status code

Status Codes

  • MS::kSuccess operation successful
  • MS::kFailure there is no current element

MItSelectionList::selItemType MItSelectionList:: itemType ( MStatus * ReturnStatus )

Description

Returns the current selection item type.

Arguments

  • ReturnStatus Status code

Return Value

  • 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 MItSelectionList:: setFilter ( MFn::Type filter )

Description

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

Arguments

  • filter The MFn::Type that you will be included in the iteration. See MFn.h for possible types.

Return Value

  • Status code

Status Codes

  • MS::kSuccess The filter was successfully set
  • MS::kFailure The was an error setting the filter

bool MItSelectionList:: hasComponents ( MStatus *ReturnStatus) const

Description

Returns whether or not the current selection item has components.

Arguments

  • ReturnStatus Status code

Return Value

  • 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

This class has no child classes.


Autodesk® Maya® 2008 © 1997-2007 Autodesk, Inc. All rights reserved. doc++ Copyright