In the file below, there is a mess-h… Composed of 26 faces, some overlapping, some inverted normals. In a few seconds I can draw four 3 and 4 point surfaces to create the clean planar surfaces that this mesh represents. However, I need to automate this for many objects (and this is an extremely simple case).

My idea was to get the normal or the plane for each mesh face and somehow compare all to come up with the 4 unique planes that they lie in, once I have that it’s not too hard to extract the faces that lie in each plane and get their combined silhouette, which can then be automatically cleaned (curve boolean) and surfaced.

I guess the best way is to work with the mesh face normals; what I don’t know is how to take a collection of vectors that contains sets of similar but not identical normal vectors (floating point and other fuzz) and come up with one unique vector for each set which can then be used to construct the planes (origin in this case doesn’t matter).

I see there is an EpsilonEquals method to compare two vectors, I guess I could start with that, but I was wondering if anyone has a better/simpler idea. TIA.

I ended up implementing my own brute force pseudo-set method, looping through the list of all the normal vectors and comparing each one in the list to all of the existing ‘unique’ ones via Vector3D.IsParallelTo(Vector3D,Tolerance) and if no parallel match is found, add that vector to the set of unique ones. Works OK, what I found is that the mesh faces in the example above actually are not all that coplanar, I have to set the angle tolerance to about 0.5° to get the 4 unique planes. Bad meshes and far from the origin (georeferenced) is not a good combination.

I’m thinking that maybe instead of using the first found unique vector in the list and just ignoring the others that match, I should make collections of all the ‘similar’ vectors and then average the collection afterwards, will see if I need that improved accuracy.

Yes, considering that, just means that I need to track the mesh face area along with its index, etc. More bookkeeping.

Yes - but I am only using this to check if a mesh face is “close” to being in a certain plane - the original mesh faces that are close will be used to get the silhouette. Yes, the potential for everything pulling apart here is large.

So I did manage the extraction of the meshes for each plane, and was able to create closed loops via Silhouette - the trapezoidal faces are slightly out of planar strictly speaking, but seem to make planar brep faces anyway that are close enough to join without any internal naked edges. I was left with two open curves from the Silhouette operation (red).

So this simple example works more or less, however, I am not sure it will work on anything else, the problem area is making sure the outer borders are closed clean curves… The trapezoidal faces may not always be planar enough to make planar faces. I will continue playing with it a bit, this is more of an intellectual exercise to try and keep my few remaining brain cells from falling asleep permanently.

It’s based on @jeremy5’s suggestion to use the normal of the largest face and, in this definition, is hardcoded to the 4 largest faces.

Which, in all likelihood, this one also will
… and it doesn’t even join all 4 surfaces up into a single nice polysurface… MeshPlaneDetection.gh (20.2 KB)
-wim