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


On Thu, Sep 20, 2018 at 9:29 AM miarmy <[email protected]> wrote:

> 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 [email protected].
> 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 [email protected].
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.

Reply via email to