MItSelectionList
is a wrapper class containing selected objects. This can either be a copy of the global active selection list, or a list you build yourself.
MItSelectionList
lets you filter the objects on the selection list to only see objects of a particular type (MSelectionList
does not let you filter selected objects).
MGlobal::getActiveSelectionList( list );
for ( MItSelectionList listIter( list ); !listIter.isDone(); listIter.next() )
{
listIter.getDagPath( node, component );
nodeFn.setObject( node );
cout << nodeFn.name().asChar() << "%s is selected” << endl;
}
The MSelectionList example can be changed with this code fragment to use MItSelectionList
instead to iterate through the selection list. This produces exactly the same results as before when selecting objects.
You can easily change the code to only look for objects of a particular type. For example, changing the constructor of the selection list iterator to:
MItSelectionList listIter( list, MFn::kNurbsSurface )
causes the loop to only iterate across selected NURB surfaces—it also ignores surface CVs. If, however, you wanted to just iterate across selected surface CVs, you would change the iterator to:
MItSelectionList listIter( list, MFn::kSurfaceCVComponent )
which would only iterate across surfaces with selected CVs.