How to get numerical Point List for Index sorting?

Hi,
I have some rotated rectangles that I need to re-rotate.

For some reason I just fail to properly aligned these.

I tried varies methods, but none seem to work (attached a method using eval surface to align based upon frame direction. But still these fail on some occassions ).

I think that sorting by their Point List values might be the way to go. For this I need to get these numbers, so I can sort based upon these values.

Is there a way to retrieve the numbers as displayed by the Point List component in python? (which I don’t master :wink: )

As image explains this probably better, I want all my rectangles to have point index ‘0’ to be in the upper-left corner


Point_Order.gh (37.7 KB)

(For context: I want exploded these rectangles in individual lines, and make for each rectangle edge a ruled surface between opposing rectangle edges (so a ruled surface from one rectangle to the next one in all 4 directions. With a matching order i can just draw lines between corresponding index members)

This can be done by extracting the control point with the lowest X value and moving the seam to that point.

Point_Order.gh (42.8 KB)

1 Like

Hi @martinsiegrist , thanks, but this fails when coordinates have the same x value (a.k.a. when rectangle is straight)), like in attachment. I tried sorting by X first and then Y, but this is also not flawless
point_list_2

Essentially I want to:
draw connected lines in -X and X direction between points 3>0 and 2>1 (of neighboring rectangle on left and right side)
draw connected lines in -Y and Y direction between points 1>0 and 2>3 (of neighboring rectangle on up and bottom side)

I didn’t look at all the curves, sorry.

How about using a plane through shape component and then get the closest point from the upper left corner? Works in 2D but your curves are 3D so we need to project the points to the XY plane for the closest point evaluation.

Point_Order.gh (53.9 KB)

Close :wink: but I think this methods also just doesn’t seem the right approach. Basically want I want to achieve is the following

Seems so easy :wink:

:slight_smile:

any chance those rotated surfaces were also generated by a GH script?
it would make life so much easier… :slight_smile:

1 Like

Hi @martinsiegrist That seems just like it . Mind share the gh file?

This is what I have tried, but as you can see, some lines won’t find the right neighbors because of incorrrect sorting, making for a ‘ugly’ surface down the line.


Join_Lines.gh (33.5 KB)

Something doesn’t work at the border. Instead of trying to get the correct four points for every surface along the border, it might be easier to get rid of the outer segments.

sorting.gh (33.0 KB)

sorted_clipped.gh (41.9 KB)

@martinsiegrist , that’s an interesting approach. Thanks for spending soo much time in assisting me. When i tried to adjust it for my script, I noticed a strange behavior. If I change the U and V (so the size of the grid) in your script it fails. See attached image. It’s because the closest point search finds the same points twice

I’ve looked if if I can prevent this, but the orientation of the planes is the result of galapalos solver

You got me, it’s an interesting problem…

It fails when a shape is rotated diagonally.

Not sure what to do yet.

Nothing simple about this, as defined. I think @inno is right, if you started with a grid of unrotated surfaces it would be relatively simple; then make the rotations and keep the connections, voila! However, it might be necessary to limit rotations to less than 45 degrees.

This cluster generates the shortest line between adjacent rectangles, which is useless.


Point_Order_2022Oct19a.gh (34.9 KB)

P.S. This is more interesting, needs work, but again, the 45 degree rotations cause ambiguity.



Point_Order_2022Oct19b.gh (35.4 KB)

P.P.S. Another valiant failure, but better…


Point_Order_2022Oct19c.gh (37.8 KB)

1 Like

I got a little lost with my flattened grid which I should not have flattened and was somehow guessing that the inner quad we are looking for would be the smallest surface area of all quads possible with the 8 points but it’s not always the case. It didn’t take me the last 4 hours to figure out all combinations… well almost. I was calculating all possible quads using a python script with itertools and permutation, then got rid of duplicates and curves where two points are too close together… At least I learnt how to get combinations.

sorted_clipped_permutations.gh (39.2 KB)

I’m not going the extra step of connecting all of the parts but the sorting bit can be solved with some help from the convex hull. It will deal with the winding of the joined curve. I used a bounding box to shift the list so the ‘leftmost’ point is first. take a look

Point_Order_HullHelper.gh (43.5 KB)

1 Like

Works nicely on the example file:

Point_Order_HullHelper.gh (50.7 KB)

Updated my definition too:

sorted_connected.gh (25.6 KB)

1 Like

Awesome work guys @andy.vanmater , @Joseph_Oster and @martinsiegrist . After spending 2 frustrating days, I am so thankful you’ve managed to help me in the best possible way. You are the best. Thanks so much. Hope to repay it in the future

PS: always great to see how other people are using ‘obscure’ components i’ve never used before

3 Likes