While trying some basic programming in Maya I came across the "MitMeshPolygon" method. Which was described as: "This class is the iterator for polygonal surfaces (meshes)."
This seemed to be what I needed, so I looked into iterators more and from what I can tell, iterators should themselves be iterable, and have a iter method. However, when trying to iterate over it python told me it wasn't iterable.
iterable = OpenMaya.MItMeshPolygon(dagPaths[0])
while not iterable.isDone():
print(iterable)
print(dir(iterable))
<maya.OpenMaya.MItMeshPolygon; proxy of <Swig Object of type 'MItMeshPolygon *' at 0x0000021A9159D630> >
['class', 'delattr', 'dict', 'dir', 'doc', 'eq', 'format', 'ge', 'getattribute', 'gt', 'hash', 'init', 'init_subclass', 'le', 'lt', 'module', 'ne', 'new', 'next', 'reduce', 'reduce_ex', 'repr', 'setattr', 'sizeof', 'str', 'subclasshook', 'swig_destroy', 'weakref', 'center', 'className', 'count', 'currentItem', 'geomChanged', 'getArea', 'getAxisAtUV', 'getColor', 'getColorIndex', 'getColorIndices', 'getColors', 'getConnectedEdges', 'getConnectedFaces', 'getConnectedVertices', 'getEdges', 'getNormal', 'getNormals', 'getPointAtUV', 'getPoints', 'getTriangle', 'getTriangles', 'getUV', 'getUVArea', 'getUVAtPoint', 'getUVIndex', 'getUVSetNames', 'getUVs', 'getVertices', 'hasColor', 'hasUVs', 'hasValidTriangulation', 'index', 'isConnectedToEdge', 'isConnectedToFace', 'isConnectedToVertex', 'isConvex', 'isDone', 'isHoled', 'isLamina', 'isPlanar', 'isStarlike', 'isUVReversed', 'next', 'normalIndex', 'numColors', 'numConnectedEdges', 'numConnectedFaces', 'numTriangles', 'onBoundary', 'point', 'polygon', 'polygonVertexCount', 'reset', 'setIndex', 'setPoint', 'setPoints', 'setUV', 'setUVs', 'tangentIndex', 'this', 'thisown', 'updateSurface', 'vertexIndex', 'zeroArea', 'zeroUVArea']
I want to iterate through all the polygons and "getArea", but right now I have no idea how to do it, everything I read tells me iterators should be iterable, but the program tells me otherwise. What am I not understanding here? How do I use these methods to get specific information concerning the object indicated by the DagPath?
for item in iterable:
not work? – 9769953__next__
method, so you should be able to callednext(iterable)
inside awhile True:
loop, and it will raiseStopIteration
once done. – 9769953count
,next
, andcurrentItem
look like they might be the way to go, but I don't know enough about Maya to be confident in how this thing should be used. – user2357112 supports Monica__next__
listed in the output ofdir()
? – 9769953__iter__
, which all iterators are supposed to have. I guess this thing might be half-usable as an iterator. – user2357112 supports Monica