Orienting all curves in the same direction in UV-cells

Hi!

I’m trying to generate a repeatable pattern within a UV-mesh. In the script I’ve generated polygons using the cells center point and from that polygon I’m extracting the discountinuity points to use for my pattern. It’s almost working but for some reason a few of the polygons have different directions then the rest and I can’t for the life of me figure out why. Out of approximately 300 cells only like ten or so polygons are differing from the rest. Do you have any suggestions how I can make all the polygons within the cell be of the same direction.

I don’t know if my explanation is all that clear, I’ll include the rhino and GH-file. I’ve highlighted the part I’m struggling with in a group where I’ve evaluated the length of each curve. Would really appreciate any suggestions you have.

Thanks in advance!

Pattern in UV cells.gh (29.2 KB)
Pattern in UV cells.3dm (2.8 MB)


Pattern in UV cells_re.gh (31.3 KB)

That is…exactly what I was trying to achieve! Many thanks to you Kim for taking the time and assisting me!