Sort Planar Surfaces (or Planes) by Orientation

Hi,
I want to sort planar surfaces by their orientation, and just cannot find the right method.

As example I made a grid surfaces with incrementally increasing orientations (in 2 - axis). I randomize this grid. And now I need to find a way to get back to the original configuration.

In my real case I get planar surfaces with all kinds of different orientations, and I need to align them with ever increasing values for 2 axis.

I attach both the .gh and printscreen. The left of the color image mimics the randomised input geometry, and right grid mimics my desired output (or any other configuration as long as I get transition with surfaces from low to high angle values).

Any help directing me towards the right solution is greatly appriciated
Sort_Srf_by Orientation.gh (59.4 KB)


not sure if I have understood correctly: surfaces are oriented the right way but their location is wrong, so you want something like “which goes where?” -already knowing that each of them will have a particular location?-

or you want to know how much each surface should rotate on both axis, in such a way its final orientation will match the correct one?

Hi Inno,
The surfaces are oriented in a certain way in a grid, but i don’t care about their location.

All I want to achieve is move the planes inside the grid so that in the new position the planes are aligned by their orientation. Essentially getting the plane XY and XZ or YZ angles and remapping that along a X and Y axis. So for example at 0,0,0 the plane with the lowest orientation is located, while in the oppositie corner of the grid, the plane with the highest angle for both XY and XZ or YZ angle is placed.

Hope this makes it clearer. Thanks !

Arghh … so annoying :wink: How the most complex things flow so easy out of the mind, and the most basic stuff kills the workflow.

I line with sometimes a solution is just right in front of us, all it requires is looking through a different eye … it will be much appreciated if someone has some suggestions on how to approach this seemingly super simple task … just spent a frustrating day on solving this.

Here’s a way to randomize your list of surfaces then sort them back to the original data structure and positions.

Sort_Srf_by Orientation_re.gh (66.4 KB)

-Kevin

@kev.r WOW! awesome and elegant solution. Life saver and exactly what I need. For context, I needed sorting working to get a simpler, more aesthetic mesh used later on in my script to make fabrication a lot simpler. Again, super thankful that you are willing to spending your time on helping me out here.

@kev.r Just so I understand the reasoning behind it, why did you first 'Position All Surfaces
At World Origin" and “Randomize that List”.

Hi Kevin, I was a bit too optimistic. When I pick another random configuration for the planes (for now randomly orientated), the script fails. Just cannot seem to get to grips to this, and understand why this actually happens, and your solution only seems work for the giving surfaces as initialised in the file. See attachment, hope you can have another look. Thanks
Screenshot 2022-08-01 at 14.05.54
Sort_Srf_by Orientation_re_01.gh (150.8 KB)

I just did that to get to a random starting point.

I wrote the file I uploaded based on the characteristics of the surfaces you provided.

This is a more general approch:

Sort_Srf_by Orientation_re_01a.gh (147.9 KB)

You asked:
PS: Why does order matter of first Y and then X matter?, results change when Sorting for X frist, and then Y

The first sortation determines the order of the branches in the DataTree, the second sortation determines the order within each branch.

You can also get differing results by using or skipping the Flip Matrix component or by providing a plane to the P input of the Angle components.

-Kevin

1 Like

Awesome!

Hi Kevin,
Your script works like a charme. Super happy with it.

I’ve been playing with your suggestion for using the 1st and 2nd sortation to determines the visual output. I combined that in the script. Instead of manually going through each of the possible 78 combinations ( 6 x 13 sortations) I am looking for a way to display all these combinations in a grid, so I can more easily select the preferred option.
Normally that wouldn’t be such a bit deal, but I get stuck because of the sorting and partition operations messing up the branches. It’s be a couple of years since I last used GH so I am a bit rusty with the tree structure operations. The method I tried is to Shift Paths by 2, one for the 1st order and the second for the 2nd sortation

Hope you can have a look and point me in the right direction.

one of the combinations


and another one

and attached .gh file
Sort_Srf_by Orientation_Array.gh (100.4 KB)

@crz_06 have a look at this:

I culled the banches that were causing the "vector is zero-length after projection onto the Plane" errors in the Angle components. This reduced the combinations from 78 to 48.

Also displaying the surfaces after going through a Flip Matrix component, so 96 combinations in total.

Sort_Srf_by Orientation_Array_re.gh (167.0 KB)

Could definitely use some clean-up and optimization, but it should give you some ideas.

-Kevin

1 Like

I sincerely appreciate your help with this project, Kevin - I owe you one