The problem is this line: vector = meshIter1.getNormal(normal, ObjectSpace)
getNormal returns an MStatus object, which Python does not use, and which will cause Maya to crash unfortunately if you try to capture it in Python. Depending what you are wanting to do btw a better approach is: normals = OM.MVectorArray() meshIter1.getNormals(normals, OM.MSpace.kObject) Thus you get all the normals in a single API call instead of looping through the whole thing and can then do whatever with them in Python. The more API calls you have, the more translation happens across the SWIG layer, which will cause your code to execute slower. On Fri, Apr 9, 2010 at 8:27 AM, johnvdz <[email protected]> wrote: > Hi all, > > just trying the get the Normal direction of a vertex so i can offset a > point locally from its Normal. > > at the moment i cant get a value from the Normal at all? > > import maya.OpenMaya as OpenMaya > import maya.OpenMayaMPx as OpenMayaMPx > > selList = OpenMaya.MSelectionList() > OpenMaya.MGlobal.getActiveSelectionList(selList) > dag1= OpenMaya.MDagPath() > selList.getDagPath(0,dag1) > meshIter1 = OpenMaya.MItMeshVertex(dag1) > > ObjectSpace=OpenMaya.MSpace.kObject > > while not meshIter1.isDone(): > p1 = meshIter1.position(ObjectSpace) > print p1.x,p1.y,p1.z > normal=OpenMaya.MVector() > vector = meshIter1.getNormal(normal, ObjectSpace) > meshIter1.next() > > at the moment this crashes maya after it has finished the loop. i think its > because i normal=OpenMaya.MVector() is inside the loop. > > i have tried this outside the loop but i get "None" as a Print result of > 'vector'. I'm pritty new to API so i could have done a few things wrong. > > anyway any answers would be appreciated > > john > > -- > http://groups.google.com/group/python_inside_maya > > To unsubscribe, reply using "remove me" as the subject. > -- http://groups.google.com/group/python_inside_maya
