I’m trying to get the closest point (actually the closest normal, but the problem is more obvious here) on a mesh relative to a point in space. I came up to the api.openmaya library and the MFnMesh.getClosestPoint method.
I think i managed to relate properly the actual mesh to an openmaya object, the MFnMesh. Now it’s almost working, but the point resulting ist not really the closest one as you can see on the picture.
Here’s my code :
#create an MFnMesh for the selected mesh obj = cmds.ls(sl = True) selection_list = om.MSelectionList() selection_list.add(obj) obj= om.MObject() dpath= om.MDagPath() dpath= selection_list.getDagPath(0) MObject=om.MFnMesh(dpath) #calculate and display closest point MPoint = MObject.getClosestPoint (point, 4) displayedCurve = cmds.curve( p=[(0, 0, 0), (MPoint,MPoint,MPoint)] )
Maybe i’m missing something on the getClosestPoint utility ?
I just discovered the whole openmaya stuff
Thank’s for helping