How to use curve closest point with Python in GH


I think this is very easy to solve issue, but I’m stuck on it for quite some time.
I think I’m messing up which documentation to use and how to work with Rhino objects, how to work with GH objects, and can’t solve it.

Basically, I need to get distance to curve closest point from point.

Could anyone point me to the correct documentation that should be used for GH Python?

One thing, that did at least something was:

    for j in range(len(temp_curve_list)):
        d = curve_list[j].ClosestPoint(curve_middle_points[i])

It returns a tuple of boolean and distance.
In larger test scenario the distance value sometimes is a number, sometimes it returns “0.0” where it shouldn’t.
So now I’m trying to test exact method, that should be used.

When using “ClosestPoint” in the small script in picture above, it gives me error, that ClosestPoint requires two arguments, while in a larger script and in code snippet above, it works with one argument. (However, with I think, incorrect results).

I’m now going in circles and would be very glad for any directions, how it should be done correctly.

Best regards,

Hi @janis.goldmanis ,

I think you have your GhPython y input set to the type Line.
Line.ClosestPoint method requires two inputs:

If you set your y input type to Curve, it will ask for only one input:


Curve.ClosestPoint returns a boolean that indicates succes and the parameter along the curve where the closest point is. You can unpack these values directly (i.e. using tuple unpacking) and then call these two methods to compute the distance: (5.0 KB)


Huge thanks to both of you!!!
I don’t know why, I imagined that it returned distance. Numbers where similar enough, and I didn’t look further into that.
If it’s parameter, it’s much clearer, why it was 0.0 for so many cases.