Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Wednesday, 14 December 2011

Locking vertex normals using Maya API

OpenMaya.MFnMesh.lockFaceVertexNormals is the function to use but it's got not very clear from the documentation what you need to pass to it. It needs an array of faces and of vertices formed like this:
faces = ( 0, 0, 0, 0, 1, 1, 1, 1 )
verts = ( 1, 2, 3, 4, 1, 2, 5, 6 )
In this example the face with index 0 will have vertices 1, 2, 3 and 4 locked. Face 1 will have vertices 1, 2, 5, 6 locked. This code will lock all vertex face normals:

verts = OpenMaya.MIntArray()
faces = OpenMaya.MIntArray()
vertsForFace = OpenMaya.MIntArray()
for faceID in range( meshFn.numPolygons() ) :
meshFn.getPolygonVertices( faceID, vertsForFace )
for i in range( vertsForFace.length() ) :
faces.append( faceID )
verts.append( vertsForFace[i] )
meshFn.lockFaceVertexNormals( faces, verts )

Thursday, 13 October 2011

Wing IDE up and running!

Got Wing IDE set up and debugging Maya. This page was very useful for that: Mel Wiki. However I had to change something to get it to send hi-lighted text from the editor to Maya. The line:
af, socktype, proto, canonname, sa = res[0]
became:
af, socktype, proto, canonname, sa = res[1]