Curves order

Hi All I have a list of some curves , like in first the attachment.

There is a way to make directions match like in the second attachment?


Step 1 would be to define the rules and the workflow:

How do you decide what the first curve is and what are the rules for subsequent curves.

From there you can start building the flow and code functionalities.


Thank you for replay. The curves are in order as in the attachment, from 1 to 6. So at index 0 i will have curve with dot “1”. The curves may have the direction like in the attachment 2 or the opposite direction (this is to semplify respect to random directions).

Unfortunately I know I asked for something too general without specifying precise rules, the fact is that I’ve been trying to define those rules for a while and I was hoping that some input would help me

A rule that applies to the example set is:
For curve(0) the start is the extreme farthest from curve(1) midpoint.

For all other curves:
Startpoint curve(n) is closest to midpoint curve(n-1)

Does this make sense?

Thank you very much , i tried it and I think it is not the right logic. see the attachment please and run test command. As you can see some directions are wrong
test.cs (4.8 KB)
testcurveintersez.3dm (119.3 KB)

How about:

Create a vector from midpoint curve0 to intersection point curve0/curve1. if direction of curve matches vector, do nothing. else flip direction of curve.

If you dont know the order of curves, find the curves which have only one intersection with another curve. from there on, you could go either way and apply above logic.

Thank for the idea.I know exactly the order of the curves, it is a list. I would like to try what you suggested but :first i would like to know the algorithm of rhino “match direction” to use it with a logic and second i have to notice that the intersection of n curve with n+1 curve may be null !!!


I’m only familiar with python and don’t have the means at hand to run your example.


It is not a problem, but i need to do that tomorrow , because today i have to do an important commision. I will write it in python and post here

and flip accordingsly.

convert to line and use linelineIntersection.