Maya Python API 2.0: no iterators?

I’m trying to write a script for Maya 2013 using the Maya Python API 2.0. I just noticed that it is missing all of the iterator classes, like MItMeshEdge, MItMeshPolygon, and MItMeshVertex. I know that not all of the classes have been implemented yet. Does anybody know if there is a specific reason these classes haven’t been implemented? (Maybe they aren’t needed in API 2.0?) Or are they supposed to be implemented in the future?

You are allowed to use both APIs as long as you don’t mix the objects.
From Maya documentation:

New and old API classes can be used within the same script, but their objects are not interchangeable. Thus, you can do this:

import maya.api.OpenMaya as newOM
import maya.OpenMaya as oldOM

newAttrObj = newOM.MObject()
oldNodeObj = oldOM.MObject()

newAttrFn = newOM.MFnAttribute(newAttrObj)
oldNodeFn = oldOM.MFnDependencyNode(oldNodeObj)

OKAY: Print names from old and new function sets.

print(“Attribute name is %s.%s” % (oldNodeFn.name(), newAttrFn.name))

but not this:

import maya.api.OpenMaya as newOM
import maya.OpenMaya as oldOM

newAttrObj = newOM.MObject()
oldNodeObj = oldOM.MObject()

BAD: Passing an old API MObject to a new API method.

newPlug = newOM.MPlug(oldNodeObj, newAttrObj)

I think the idea is to use methods from the function set, i.e. MFnMesh with Python’s for loop. Not sure :stuck_out_tongue:


import maya.api.OpenMaya as om2

sel = om2.MSelectionList()
sel.add('pSphereShape1')
dag = sel.getDagPath(0)

mesh = om2.MFnMesh(dag)

for i in range(mesh.numVertices):
	point = mesh.getPoint(om2.MSpace.kWorld)

I think there are a few things you can do in the iterator classes that you can’t do in the regular MFnMesh class. For example, in MItMeshPolygon, there are functions like isLamina() and getArea(). Luckily I am not using any of those functions right now. What I am trying to do is iterate over a subset of the mesh’s faces, and then iterate over the triangles of those faces. I have been able to do it using only the MFnMesh functions; it just requires keeping track of a lot of array indices.

I saw the documentation where it says you can use both APIs. I’m trying to avoid that if possible, because I’m afraid I would mix them unintentionally. (Maybe there’s some sort of naming convention I could use to tell my variables apart?)

personally i would really just stick with api1. with 2.0 what works is nice, and easier to write, but it lacks so much, so your just best sticking with 1