Initializing MItMeshPolygon iterator with component (edge / vertex) in Python

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!

This workaround made the trick - although I’m still interested in the original method!

while not mItVtx.isDone():
    	vtxId = mItVtx.index()
    	point = mItVtx.position(om.MSpace.kWorld)
    	faceList = om.MIntArray()
    	mItVtx.getConnectedFaces(faceList)
    	mFnComp = om.MFnSingleIndexedComponent()
    	comp = mFnComp.create(om.MFn.kMeshPolygonComponent)
    	map(mFnComp.addElement, faceList)
    	mItPoly = om.MItMeshPolygon( dag_path, comp )
    	while not mItPoly.isDone():
    		# do stuff
    		mItPoly.next()
    	mItVtx.next()