ClosestPoint in cpython, rhinoinside

I am not able to use the method ClosestPoint for a crv


Returns typeerror:


TypeError Traceback (most recent call last)
----> 1 line.ClosestPoint(line.PointAtEnd,0.0)

TypeError: No method matches given arguments for ClosestPoint


This may be related to the “out double t” definition?

from RhinoCommon API description:
public bool ClosestPoint(
Point3d testPoint,
out double t

Hi @mads,

Let me know of this sample helps:

import rhinoinside
import Rhino
import System  # pip install pythonnet

pt0 = Rhino.Geometry.Point3d(0.0, 0.0, 0.0)
pt1 = Rhino.Geometry.Point3d(5.0, 5.0, 0.0)
line_curve = Rhino.Geometry.LineCurve(pt0, pt1)

# When calling .NET methods have return a value as an 'out' parameter,
# you need to pass as many arguments as the method requires.
# Since the concept of out arguments (or passed by reference)
# does not apply to Python, the trick is to pass some dummy arguments
# of the expected type.
dummy_out = System.Double(0.0)
rc, real_out = line_curve.ClosestPoint(pt1, dummy_out, 0.0)
if rc:

– Dale

Thanks Dale, that worked perfectly.