Discussion:
[Maya-Python] one transform node with more shape mode
miarmy
2018-09-19 21:29:15 UTC
Permalink
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?
--
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+***@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.
Justin Israel
2018-09-19 22:02:58 UTC
Permalink
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
Post by miarmy
MSelectionList selectionList;
MGlobal::getActiveSelectionList(selectionList);
MDagPath dag_path;
MItSelectionList kDagNodeSelectionList(selectionList, MFn::kDagNode);
kDagNodeSelectionList.getDagPath(dag_path);
MObject obj;
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?
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/30a38c5b-1526-48cb-860b-0f46d7708747%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/30a38c5b-1526-48cb-860b-0f46d7708747%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1ixXWrPxGCS8c0AJ7VybTS9RsqwqtnVowm%3Dwe3DttuwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...