one transform node with more shape mode

32 views
Skip to first unread message

miarmy

unread,
Sep 19, 2018, 5:29:15 PM9/19/18
to Python Programming for Autodesk Maya
hi! first, i write this code:

MSelectionList selectionList;
MGlobal::getActiveSelectionList(selectionList);
//first selection :
MDagPath dag_path;
MItSelectionList kDagNodeSelectionList(selectionList, MFn::kDagNode);

kDagNodeSelectionList
.getDagPath(dag_path);

MObject obj;
//get shape :
dag_path.extendToShape();
obj
= dag_path.node();
MFnDependencyNode meshObj(obj);

in transform node with one shape or mesh node, this code is true and it Give us the only mesh, But if the transform node had more shape node, How to find individual shapes?

Justin Israel

unread,
Sep 19, 2018, 6:03:15 PM9/19/18
to python_in...@googlegroups.com
Looking at the API docs, extendToShape() says it will fail if the transform has more than one immediate shape:
http://help.autodesk.com/cloudhelp/2018/ENU/Maya-SDK/cpp_ref/class_m_dag_path.html#a658d9664035ff84ffefa217c0e45cc88

There looks to be 2 more calls that might suit your needs:

MStatus extendToShapeDirectlyBelow( unsigned int index )
MStatus numberOfShapesDirectlyBelow( unsigned int &  num ) const

So you can check if the transform node has more than one shape, and get the exact shape index you are after.

- Justin


--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/30a38c5b-1526-48cb-860b-0f46d7708747%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages