I was doing a dummy command for debugging and testing certain funcs , and 
what I usually do is  use

MGlobal::getSelectionListByName("pSphereShape1" , sel );

now it became redundant af , so I came up with a way to get the actual 
selected mesh and shiet :

MObjectArray mesh_list;
    MSelectionList sel;
MGlobal::getActiveSelectionList(sel);
if( sel.length() == 0)
{
MGlobal::displayError("no selection");
return MS::kFailure;
}

    MItSelectionList mitsel(sel);

MObject cur_obj; 

do
{
     mitsel.getDependNode(cur_obj);
        if (cur_obj.hasFn(MFn::kMesh) )
            mesh_list.append( cur_obj );
        else if ( cur_obj.hasFn(MFn::kTransform) )
{

MFnTransform fntransform( cur_obj );
            for (int i=0 ;i < fntransform.childCount() ;++i )
{

if (fntransform.child(i).hasFn(MFn::kMesh))
mesh_list.append(fntransform.child(i));
}

}
        
        mitsel.next();

}while(!mitsel.isDone());



do you guys , do it similarly or in a different way ? 

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/a649874e-666e-4bd6-817f-ca29e44b3658%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to