How can I reorder and orient lines like this?

I have several curves that were generated outside of GH. I need to reorder them such and orient them per my sketch below. In the sketch, assume that if two curves appear to lie at the same x coordinate, they are the same. I’ve included a set of curves as a starting point. (2.3 KB)

Only the thick lines are the curves. The dotted and thin lines are just for explanation.

Do you want all the lines end-to-end in single file?

Or all the lines with the same X values aligned single file starting at the X axis?

Sorry, I guess the sketch doesn’t do the best job explaining.

The lines don’t need to be moved at all, they just need to be ordered with the directions oriented to match the sketch.

Not available for questions? Oh well, you get what you get…

Too late.

The pipes show the original position of the lines after they have been sifted into branches by rounded X values. Disable that preview (cyan group) to better see their adjusted positions, adjacent to each other starting at the X axis. (34.8 KB)

It wasn’t clear to me but I guess you want the curves (lines) in alternate branches to be flipped?

Correct. So if you were to imagine drawing the lines, you could start by going down one row, then coming back the next row in the opposite direction, then going down the next row in the original direction.

Yeah, I didn’t get that. It means the position of the lines in alternate branches must be sorted in reverse and the other set of alternate branches must be flipped. Not asking much, but you did NOTHING? (28.0 KB)

P.S. To demonstrate how robust this is you can Jitter the sequence of lines and see that it has no effect on the result.

P.P.S. And if you want to number the lines like your drawing instead of by branches (columns) as I did, you can simply flatten the input to End Points. (magenta group below) (28.9 KB)

1 Like

Well, I did sketch out my request and provide a starting point file which is more than you often get on here.

I took a stab at it but couldn’t figure out how to group the lines according to their x-coordinate value. I understand how to do it now after looking at your solution using the Set components (which I’m not too familiar with).

Thank you for putting the time into this. It’s an opportunity for me to learn more about how these Set components work.

When working with sets (or Sort Points), it often pays to round values to a few decimal places (1, 2 or 3) so they aren’t affected by tiny differences. That’s why I added the expression to the pDecon ‘X’ output. I found that pattern in the purple group on the old forum and documented it here:

I don’t think much about how it works anymore but have adapted it many times for similar issues. Just keep a copy of this file handy and copy/paste when needed: (16.5 KB)

Another example:

And another:

1 Like