How can these points be sorted correctly?

I meet with a strange demand. As the picture shows, the points are the corner-point of the offset result of the base curve. Now I get rid of the point in the right-bottom corner and want to connect them seriously to a polyline(like green sketch show). While those points cannot be sort correctly either by inner sort battery with ghpythonlib.components.SortPoints() or SortPointList method in rhinoscriptsyntax. I wonder if there is any other way to sort these points. Can someone help me solve this problem😭?

The example file is as follows, I have baked the points and curves and internalized them.
sort_point_problem.gh (5.7 KB)

You can use Sort Along Curve (AlongCrv).

Edit: Here’s a one-liner Python snippet that does the same (using a lambda function to sort by):


210909_SortPointsAlongCurve_00.gh (4.2 KB)

2 Likes

What a timely assistance!Thank you🥰

1 Like

Hello, I’m sorry to come back to ask questions after the problem is solved. I slightly change the form of the baseline and it does not sort correctly with the same method. I am confusing since there are no essential differences between the two forms. So I post the file here and hope that you can help me to find out the reason. image

sort_point_problem_21.9.12.gh (4.9 KB)

The seam (i.e. where the start and end points connect) of your closed curve is different. Causing the parameter space along the curve to perhaps be different than you expect. You can “solve” this be changing where the seam lies on the curve on like so (also note that you have duplicate points in your input list):


210912_SortPointsAlongCurve_00.gh (7.7 KB)

Though I suspect a different logic is perhaps better all together here: If your input curve is always a polyline, it’s probably better to instead identify vertices/corners you want to connect along (i.e. instead of closest points on a curve).

1 Like