Closest polyline segment index

Hi,

What would be the shortest way to get following:

  1. I have a point
  2. I have a polyline
    I need to know the closest line segment in polyline.

Is there something similar in RhinoCommon?
Or do I need to measure distance between all segments in polyline and take shortest one?

If I recall correctly, this is this method you want:

Where the integer part of the returned parameter corresponds to the segment index and the decimal part the t value along it.

Edit: Just checked, seems to be it:

180321_PolylineClosestParam.gh (11.8 KB)

2 Likes

Nice it outputs parameter with inteteger as segment id.
I remember you mentioned this before, but I did not put into my head.

Thank you Anders:)

1 Like

Haha, I had a strange sense of déjà vu as well. The Polyline class truly is a unsung hero of RhinoCommon :slight_smile: