MFnMesh::getTriangles doesn't return actual components like faces, it
returns the triangles that Maya used to render the mesh.  e.g. a
single quad face has 4 vertices, and Maya has to turn that into two
triangles to render.  This function will tell you what vertices it
used to make up those triangles.  If you go to Display -> Polygons ->
Face Triangles then you can see them displayed in the viewport.  The
"fake" edges Maya used to make up the triangles will be rendered in a
dashed line.

On Wed, Jul 28, 2021 at 6:05 PM Alejandro <voidrea...@gmail.com> wrote:
>
> Hello people !
>
> I've been trying to store faces from combined objects using getTriangles 
> method, but I think I'm using it wrong..
>
> to reproduce the issue, duplicate a sphere, move it a little so you can see, 
> and combine it into a single object, name it as "combined_mesh" then:
>
> ```
> sel = OpenMayaApi.MSelectionList()
> sel.add("combined_mesh")
>
> _dag = sel.getDagPath(0)
> _mesh = OpenMayaApi.MFnMesh(_dag)
>
> _, triangles_idx = _mesh.getTriangles()
>
> _, mObject = sel.getComponent(0)
> mfn_components = OpenMayaApi.MFnSingleIndexedComponent(mObject)
> mfn_object = mfn_components.create(OpenMayaApi.MFn.kMeshPolygonComponent)
> mfn_components.addElements(triangles_idx)
>
> selection_list = OpenMayaApi.MSelectionList()
> selection_list.add((_dag, mfn_object))
>
> OpenMayaApi.MGlobal.setActiveSelectionList(selection_list)
> ```
>
> thanks guys.
>
> --
> 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/6aa082e8-ba25-4ced-982c-58378ab6e7d0n%40googlegroups.com.

-- 
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/CALKD2Wp6qcbYramR%3DSPTYnda6RqDKx%2BTDHaeQZmmXU4-eFJjSA%40mail.gmail.com.

Reply via email to