Hi,
I would like to iterate over the vertices of a mesh and test some conditions on the faces that are connected to it.
import maya.cmds as cmds
import maya.OpenMaya as om
cmds.polyPlane( w=1.0, h=1.0, sx=3, sy=3 )
selection_list = om.MSelectionList()
dag_path = om.MDagPath()
om.MGlobal.getActiveSelectionList(selection_list)
selection_list.getDagPath(0, dag_path)
mItVtx = om.MItMeshVertex( dag_path )
while not mItVtx.isDone():
vtxId = mItVtx.index()
point = mItVtx.position(om.MSpace.kWorld)
mItPoly = om.MItMeshPolygon( dag_path, mItVtx.currentItem() ) # (kInvalidParameter): Object is incompatible with this method
#
# do stuff with mItPoly
#
mItVtx.next()
The MItMeshPolygon iterator can be restricted to the faces adjacent to a given component (for example, edge or vertex) by initializing the class to both a DAG path referring to the mesh and an MObject reference to certain components.
OpenMaya.MItMeshVertex.currentItem( ) → MObject
Get the current vertex in the iteration as a component.
Can someone please show me how to set up MItMeshPolygon the correct way with components?
Thank you!