# How to separate rectangular surfaces from a bunch of surfaces?

Hi, there are some mixed shapes. How can I separate rectangular surfaces from the other ones?

Forum-CullingRectangles.gh (27.0 KB)

This seems to work for your â€śsimpleâ€ť geometry

My geometry is not â€śsimpleâ€ť. I just have shown a small part of the hole modell. Do you know a solution that does the sperating more geometrically? This way is just culling by distance and is not that precise.

@Joseph_Oster Thank you, but it seams to me that there are some rectangular faces inside the non-rectangle group.

Green = rectangles
Blue = non rectangles

Simple was a way to say that there was just some basic shapes with no holes, curved part â€¦ that could lead to bad results.
For example I am sure my algorithm doesnâ€™t wort with diamond as the one of Joseph.

Lets come back to math and measure angles between edges if all angles = 90Â° it must be a rectangle

@laurent_delrieu Thank you, you are right. Just planar nurbs. How could your idea look like includin the angle measurement? I think there should be the option of tollerances inside, because I do not think that all surfaces are perfectly 100 % rectangles

Yes, I noticed that. Itâ€™s because your rectangles are not precise, their edge lengths arenâ€™t the same. Adding the expression â€śround(x,1)â€ť to the Len output seems to fix that - but itâ€™s dicey.

CullingRectangles_2020Apr30b.gh (32.9 KB)

Measuring angles will have the same problem when the geometry is sloppy.

let me quickly check for the hole model

Unfortunatetly I can not optimize the geo beacuse it was scanned by drone with lidar sensors

Okay, I think it is okay for most of the parts. Thanks again for your help.

check this, not the most elegant, but works here for all casesForum-CullingRectangles PS.gh (42.4 KB)

1 Like

Thank you @Piotr

You can change the expression to â€śround(x)â€ť (to the nearest integer) and change Equals (2) to Smaller (than 3) to handle squares where there is only one length for all four sides.

CullingRectangles_2020Apr30c.gh (35.2 KB)

1 Like

Clever and quick, but comparing length in sets may result that rhombs are selected as well. Am I right or not?

You can ignore it, it was just for cross-checking.

Iâ€™d like to ignore it but since I canâ€™t see it, I donâ€™t know how to wire around it?

You are right. Triangles too.

Iâ€™d love to see your solution?

It is attached to my post above.
I, basically, run bounding box plane through each surface and then measured the sum of distances from each control point to boundary of bounding box.
It equals zero only for rectangles, any other polygons are eliminated.