MeshClosestPoint problem with sample code

meshclosestpoint_testfile.3dm (118.9 KB)
I tried example code from the link below, to get a point closest to mesh, but it gives me an error message (Rhino 5). What could be the problem and how to solve it?

https://developer.rhino3d.com/api/RhinoScriptSyntax/#mesh-MeshClosestPoint

import rhinoscriptsyntax as rs
obj = rs.GetObject(“Select mesh”, rs.filter.mesh)
point = rs.GetPoint(“Pick test point”)
intersect = rs.MeshClosestPoint(obj, point)
if intersect: rs.AddPoint(intersect)

Example file included.

Error:
Message: not all arguments converted during string formatting

Traceback:
line 375, in coerce3dpoint, “C:\Users\gdlfa\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\utility.py”
line 80, in AddPoint, “C:\Users\gdlfa\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\geometry.py”
line 6, in , “C:\Users\gdlfa\AppData\Local\Temp\TempScript.py”

If you read the info at the link you posted above about MeshClosestPoint(object_id, point, maximum_distance=None), this is what it says it returns:

Returns:
tuple(point, number): containing the results of the calculation where
                      [0] = the 3-D point on the mesh
                      [1] = the index of the mesh face on which the 3-D point lies

Your code works if you change it to this (only change is the last line):

import rhinoscriptsyntax as rs
obj = rs.GetObject("Select mesh", rs.filter.mesh)
point = rs.GetPoint("Pick test point")
intersect = rs.MeshClosestPoint(obj, point)
print intersect
if intersect: rs.AddPoint(intersect[0])

-Kevin