import Rhino.Geometry as rg
from clr import Reference
def MeshClosestPointNormal(mesh, pnt, maxDist=0.0):
"""for a test point and a mesh, return the closest point, normal and face
index on that mesh.
input:
mesh - guid of a mesh
pnt - test Point3d
returns:
tuple containing (closest_point, normal, faceindex)
"""
ret_pnt = rg.Point3d(0,0,0)
ret_pnt = Reference[ret_pnt.GetType()]()
ret_nrm = rg.Vector3d(0,0,0)
ret_nrm = Reference[ret_nrm.GetType()]()
face_idx = mesh.ClosestPoint(pnt, ret_pnt, ret_nrm, maxDist)
return (ret_pnt.Value, ret_nrm.Value, face_idx)