I updated to Maya 2022 and run through my old python scripts and some of them failed to produce the same output. I reproduced the issue with a simple example. Basically, I cannot produce a MItMeshPolygon iterator from a MFnSingleIndexedComponent.
python code:
import maya.cmds as cmds
import maya.OpenMaya as om
import maya.OpenMayaMPx as omMPx
import math
cmds.polyPlane( n='myPlane', sx=2, sy=2, w=10, h=10)
selection_list = om.MSelectionList()
dag_path = om.MDagPath()
component = om.MObject()
om.MGlobal.getActiveSelectionList(selection_list)
selection_list.getDagPath(0, dag_path, component)
mItVtx = om.MItMeshVertex( dag_path )
# set up some scripting junk
intPx = om.MScriptUtil()
intPx.createFromInt(0)
intPtr = intPx.asIntPtr()
while not mItVtx.isDone():
vtxId = mItVtx.index()
point = mItVtx.position(om.MSpace.kWorld)
print('vtxId: ' + str(vtxId))
print(str(point.x) + ' ' + str(point.y) + ' ' + str(point.z))
faceList = om.MIntArray()
mItVtx.getConnectedFaces(faceList)
print('getConnectedFaces: ' + str(faceList))
mFnCompFace = om.MFnSingleIndexedComponent()
compFace = mFnCompFace.create(om.MFn.kMeshPolygonComponent)
map(mFnCompFace.addElement, faceList)
check = om.MIntArray()
mFnCompFace.getElements(check)
print('check: ' + str(check))
mItPoly = om.MItMeshPolygon( dag_path, compFace )
while not mItPoly.isDone():
point = mItPoly.center()
mItPoly.numTriangles(intPtr)
print('\tfaceId: ' + str(mItPoly.index()))
print('\tnumTriangles: ' + str(om.MScriptUtil(intPtr).asInt()))
print('\tfaceCtr: ' + str(point.x) + ' ' + str(point.y) + ' ' + str(point.z))
mItPoly.next()
mItVtx.next()
maya 2018 output:
vtxId: 0
-5.0 -1.11022302463e-15 5.0
getConnectedFaces: [0]
check: [0]
faceId: 0
numTriangles: 2
faceCtr: -2.5 -5.55111512313e-16 2.5
vtxId: 1
0.0 -1.11022302463e-15 5.0
getConnectedFaces: [0, 1]
check: [0, 1]
faceId: 0
numTriangles: 2
faceCtr: -2.5 -5.55111512313e-16 2.5
faceId: 1
numTriangles: 2
faceCtr: 2.5 -5.55111512313e-16 2.5
vtxId: 2
5.0 -1.11022302463e-15 5.0
getConnectedFaces: [1]
check: [1]
faceId: 1
numTriangles: 2
faceCtr: 2.5 -5.55111512313e-16 2.5
vtxId: 3
-5.0 0.0 0.0
getConnectedFaces: [2, 0]
check: [0, 2]
faceId: 0
numTriangles: 2
faceCtr: -2.5 -5.55111512313e-16 2.5
faceId: 2
numTriangles: 2
faceCtr: -2.5 5.55111512313e-16 -2.5
vtxId: 4
0.0 0.0 0.0
getConnectedFaces: [3, 1, 0, 2]
check: [0, 1, 2, 3]
faceId: 0
numTriangles: 2
faceCtr: -2.5 -5.55111512313e-16 2.5
faceId: 1
numTriangles: 2
faceCtr: 2.5 -5.55111512313e-16 2.5
faceId: 2
numTriangles: 2
faceCtr: -2.5 5.55111512313e-16 -2.5
faceId: 3
numTriangles: 2
faceCtr: 2.5 5.55111512313e-16 -2.5
vtxId: 5
5.0 0.0 0.0
getConnectedFaces: [1, 3]
check: [1, 3]
faceId: 1
numTriangles: 2
faceCtr: 2.5 -5.55111512313e-16 2.5
faceId: 3
numTriangles: 2
faceCtr: 2.5 5.55111512313e-16 -2.5
vtxId: 6
-5.0 1.11022302463e-15 -5.0
getConnectedFaces: [2]
check: [2]
faceId: 2
numTriangles: 2
faceCtr: -2.5 5.55111512313e-16 -2.5
vtxId: 7
0.0 1.11022302463e-15 -5.0
getConnectedFaces: [3, 2]
check: [2, 3]
faceId: 2
numTriangles: 2
faceCtr: -2.5 5.55111512313e-16 -2.5
faceId: 3
numTriangles: 2
faceCtr: 2.5 5.55111512313e-16 -2.5
vtxId: 8
5.0 1.11022302463e-15 -5.0
getConnectedFaces: [3]
check: [3]
faceId: 3
numTriangles: 2
faceCtr: 2.5 5.55111512313e-16 -2.5
maya 2022 output:
vtxId: 0
-5.0 0.0 5.0
getConnectedFaces: [0]
check: []
vtxId: 1
0.0 0.0 5.0
getConnectedFaces: [0, 1]
check: []
vtxId: 2
5.0 0.0 5.0
getConnectedFaces: [1]
check: []
vtxId: 3
-5.0 0.0 0.0
getConnectedFaces: [2, 0]
check: []
vtxId: 4
0.0 0.0 0.0
getConnectedFaces: [3, 1, 0, 2]
check: []
vtxId: 5
5.0 0.0 0.0
getConnectedFaces: [1, 3]
check: []
vtxId: 6
-5.0 0.0 -5.0
getConnectedFaces: [2]
check: []
vtxId: 7
0.0 0.0 -5.0
getConnectedFaces: [3, 2]
check: []
vtxId: 8
5.0 0.0 -5.0
getConnectedFaces: [3]
check: []
Is this a bug or am I doing something wrong? Thank you!