# Closest curve to point?

Hi all. I do have some curves and I do need to eliminate the flat parts on both ends of the curves but looks like for whatever reason I can’t calculate right the distance between the middle-points of the curves I do need to eliminate and the other curves to create a cull pattern?

Closest Curve to point.gh (27.9 KB)

Pass the curves to a curve length component and sort its output → pass the curve list to the A values of the sort component. Then cull indices 0,1,2… etc

As @adel.albloushi says you jsut need to sort by length.

You need to first shatter the curve using the inflection points.

Closest Curve to point_NL.gh (29.7 KB)

If for some other reason you want to use point proximity you can but seems like over kill

I do know about to measure the length of the segments but unfortunately I can have curve segments with the same length, so I do need to remove SPECIFICALLY that ends. Thank you.

There’s no magical algorithm. You need to use geometrical properties to select and filter.

In this particular case it just so happens that your geometry suggests that the ends of your ribbon would be the shortest curves outputed by brepedges component.

If you post a a file where the method of culling by curve length fails maybe we can figure out a way to define the proper culling filter using proper geometric attributes.

But just to reiterate, there is no universal method, only a case-by-case solution

@Cumberland

What is the issue with the definition I posted?

If the end segments are always the smallest they will always get removed. Once you join the edges and shatter with the discontinuity you will only have 4 edges per surface the very long ones and the two short ones at the end

This is the issue. The end segments won’t be always the smallest, so I can’t use the measure length of the segments.

Made some progress, now I can find two identical points, now the question it is how I can get the indices of the duplicated points into the longest tree to create a cull pattern?

Closest Curve to point_v2.gh (34.7 KB)