Detail Line grouping and moving in x and y directions

Hello everyone.
I’m working on a script. What I want to do here is to sort the curves by x or y and give them distance. I’ve used List.Slice and it seems to work fine, but it doesn’t give correct results every time. Any ideas what else I could use instead of List.Slice?

Rebar Detail.dyn (964.7 KB)

It already groups by x and y comment, but when I reorder by x or y I don’t get the correct result.

This is what I want to do and it works fine now, but by chance, I think it works correctly, I believe that a more accurate grouping will be made.

What’s the reason for the Slice nodes? Seems like you’re hard coding the slice value so you’re gonna run into issues like you mention. If you’re trying to group by location and direction then you’ll want to group by X first then group new sublists by Y (or vice versa). You might want to include some rounding if elements aren’t exactly aligned.

This is exactly what I want, I actually don’t have much trouble sorting the curves but how can I group or separate them to get into the x and y direction?

You’d have to get the curve direction (vector) and group by that, not just the geometry. It’ll be a combination of sorting and grouping.

Based on his advice I made some changes to the script and it’s working fine now. Thanks for the advice.