[Maya C++ API] Get selected vertices

MSelectionList selection_list;
MGlobal::getActiveSelectionList(selection_list);
MItSelectionList iter(selection_list);
for ( ; !iter.isDone(); iter.next()) // For each selected object
{
    MObject component;
    MDagPath item;
    mayaCheck( iter.getDagPath(item, component) );
    
    MGlobal::displayInfo( item.fullPathName() );
    
    if( component.isNull() )
        continue; // No vertices selected.
    
    MStatus status;
    MItMeshVertex vert_it(item, component, &status);
    if( status == MS::kFailure)
        continue; // the component is not a vertex (perhaps face, edge etc.)
    
    for ( ; !vert_it.isDone() ; vert_it.next() )
    {
        int af = vert_it.index(&status);
        mayaCheck(status);
        MGlobal::displayInfo(MString(" index\n")  + af );
    }
}

more here

No comments

All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Spam bot question: