MItMeshFaceVertex confusion

154 views
Skip to first unread message

Andrew

unread,
Aug 25, 2008, 1:28:36 PM8/25/08
to python_inside_maya
Hey all, so I'm building a polygon surface exporter with which I need
to extract info for each face vertex. I am trying to do this using
MItMeshFaceVertex, however it doesn't recognize changes to the mesh
such as changing the vertices positions, even if I save the scene and
reload it. It does recognize the changes once I do something like Poke
Face or Split Poly Tool. In contrast, getting positions using
MItMeshPolygon or MFnMesh works all the time, which I don't understand
why this is different.

This is my first project using the API, so any insight as to what's
going on would be very helpful. I'm running this test with a simple
poly plane in the scene:
cmds.polyPlane(w=1,h=1,sx=1,sy=1)

#---------------------------------------------

import maya.OpenMaya as om

selList = om.MSelectionList()
om.MGlobal.getActiveSelectionList( selList )
sel_iter = om.MItSelectionList( selList, om.MFn.kMesh )

node = om.MDagPath()
sel_iter.getDagPath( node )


point_list = []
vertFaceIter = om.MItMeshFaceVertex( node )
while not vertFaceIter.isDone():
point_list.append( vertFaceIter.position( om.MSpace.kTransform ) )
vertFaceIter.next()

print ['%.1f, %.1f, %.1f'%(p.x,p.y,p.z) for p in point_list ]


pointArray = om.MPointArray()
polyIter = om.MItMeshPolygon( node )
polyIter.getPoints( pointArray, om.MSpace.kTransform )

print ['%.1f, %.1f, %.1f'%(p.x,p.y,p.z) \
for p in [pointArray[i] for i in xrange(pointArray.length())] ]


pointArray = om.MPointArray()
meshFn = om.MFnMesh( node )
meshFn.getPoints( pointArray, om.MSpace.kTransform )

print ['%.1f, %.1f, %.1f'%(p.x,p.y,p.z) \
for p in [pointArray[i] for i in xrange(pointArray.length())] ]

Dean Edmonds

unread,
Aug 25, 2008, 6:47:30 PM8/25/08
to python_in...@googlegroups.com
On Mon, Aug 25, 2008 at 10:28 AM, Andrew <and...@kinetifex.com> wrote:
>
> Hey all, so I'm building a polygon surface exporter with which I need
> to extract info for each face vertex. I am trying to do this using
> MItMeshFaceVertex, however it doesn't recognize changes to the mesh
> such as changing the vertices positions, even if I save the scene and
> reload it. It does recognize the changes once I do something like Poke
> Face or Split Poly Tool. In contrast, getting positions using
> MItMeshPolygon or MFnMesh works all the time, which I don't understand
> why this is different.

There's a bug in MItMeshFaceVertex::position(). It doesn't take tweaks
into account.

I've entered a bug for it. In the meantime you'll have to use one of
the other methods that you mentioned to get the proper vertex
position.

--
-deane

Andrew Gerard

unread,
Aug 25, 2008, 7:01:44 PM8/25/08
to python_in...@googlegroups.com
ah ok, alright thanks for heads up

-Andrew
Reply all
Reply to author
Forward
0 new messages