Reorder closed curves by line orientation

Hello,

I tried to find a solution in the forum, but unfortunately n.

I’d like to reorder a bunch of closed curves, which normally comes in random order. To guide the new positions I used a curve to orient them along it. Then moving the curve to the opposite side, I can take their orientation with them. If I mirror it, I get the reverse.

Mess order.


New order:
image

I’ve got the new location, but I stuck in how reconstruc them in their new position, in order to use them in this way.

Thank you!

Curves Order.3dm (71.1 KB)
Curves Order.gh (17.7 KB)

try this
cg.gh (8.6 KB)

2 Likes

Fantastic thats the way! Thakyou for your time!

Taking inspiration from Seghierkhaled sort method, I thought this could make a useful tool, so I made a quick Python script. Maybe it is useful to others too, so thought I would share.

I haven’t covered all basis, at the moment, but could add more. Right now I just have: X, Y, Z, X-y (where X is dominant, then Y), and Y-x (where Y is dominant, then X). I also have positive and negative values for the sort direction.

You dont need the additional curve to the right to sort with this method.

cg_V2.gh (10.0 KB)

Edit: I haven’t fully tested it, so if you find any issues, let me know.

2 Likes

Hi @Adam_M ,

Great solution as well! Worked like a charm! and I’m sure this such of solution going to work for most people over here.

Besides my previous question about how to order curves position, I would also like each of them has its control points remapped, as shown in the figure below:

Remapped order:

I’m trying to do this mainly because polylines comes in a mess order and most of them comes in flipped or drew in most variant forms ever. In order to my definition works fine I need the points were mapped correctely.

Common order of points:

@Adam_M I tried to use your definition to do this, but I failed. Do you have any idea to perform it this way?

Than you so much for your time!

There are many was, depending on what you need. I’m not sure if the actual point order is important to you, or if you just want to unify the curve direction. Attached is an example of both. Sasquatch also has a Sort Points Polar component, if that might be usefull for you.

PointCommonOrder.gh (14.4 KB)

1 Like

Thanks for your reply @Adam_M!

Sasquatch only works in Rhino 6, I’m still using Rhino 5.

The point order is important for me because part of my code is about labeling this closed curves, making use of aligned dimensions.
I do import my curves into GH from Rhino using a layer selector, so I can’t control the order which curves is going to be the first picked one, then ‘Flip Curve’ component selecting one of them as a “correct one” in terms of curve direction doens’t work for me, I tried it before.

See what I’m talking about:


The first closed curve is the correct one, because X and Y aligned dimensions are set on X in lower position (left to right/0 to 1) and Y right side (down to up/1 to 2). It’s because the point order is important por me.

Imagine a bunch of curves, all points not ordered, I have to flip or rotate manually on Rhino the “incorrect ones”, to get this type of reading.

I tried your definition but failied for me.

Thank you so much for your time, it’s helping me alot!

PointCommonOrder_2.gh (9.4 KB)

I tried to flip the curves using a manually drawn one, but it failed. :frowning:



Why only second curve was affected by flip and its resulting is not equal as the guide one?

Thank you!

try this may help you

points order.gh (9.5 KB)

1 Like

You can also try this:
PointCommonOrder_3.gh (10.7 KB)

1 Like