Clean up polysurfaces/Join polysurfaces

I have a set of buildings which are made up of polysurfaces. I want to join them in order to remove the diagonal lines through the buildings like in the image. I have tried several ways, but can’t get the polysurfaces to all or most of them to join. Is there a method in grasshopper/script to clean these buildings(even if it means some buildings are excluded due to complexity)? I attached a zip file of the rhino file.

context (7.0 MB)

Hi @Erick1830_Romero ,

You can run the Boolean Union command followed by MergeAllCoplanarFaces command to get rid of any lines dividing a single face.

Keep in mind that if the neighboring faces are even slightly non-coplanar to one another, you will end up with a seam line “kink”.

Also, every so often a building has a 2D plane that is coplanar with the face of one of the building pieces and this results in a Boolean Union error.

I recommend running the Boolean Union command on a couple buildings at a time and if one doesn’t work , join pieces of the building at a time until you find the bad 2D duplicate face.

You can right click mouse to keep repeating the same command.

Sometimes I enjoy repetitive tasks such as clicking the mouse over and over so I went ahead and cleaned all your buildings for you :rofl:

If you really do need a script I can help with that, GH doesn’t like the “offending” faces but we could make a quick algorithm to cull those of course.

For now though this file should be the result you are after.

20230905_context (2.3 MB)


Thank you, very helpful. In gh, how would I cull those faces? The original model is bigger than the original and I’m at a point where I can’t find some of the “offending” faces.

You could cull against the volume of said objects.

If a volume is null it means its a 2D stray surface or an unenclosed brep.

Model Space (Stray Surface Highlighted):



Here’s an algorithm that should be able to rebuild all your buildings MUCH faster than checking bad objects and then running boolean operations (which still fail from bad geometry sometimes)

That being said it still took 40 seconds to run on all your buildings so you may want to break up chunks and bake each chunk. just a thought.

Model Space (Example Cleaned Buildings On Right In Light Blue):

All buildings cleaned:

Graph Space: (2.7 MB)

For portions of the script, it works perfectly, but other parts I keep getting an error and I am not sure why. I attached the rhino file I used. But that script will come in handy in the future! (12.5 MB)

1 Like

While your other data set had 0 “bad objects” this data set returns 34 bad objects when the Rhino command “selbadobjects” is ran.

I’m going to delete these first and then attempt the script and see if it yields a better result.

An example of one of these bad objects is a 2D surface in between the 3D volumes and that 2D surface also happens to have a random line extending off of it into 3D space.

Things like that could potentially mess up the logic.

Bad Objs (Yellow):

Additionally this data set contains inconsistent building “base heights”

I did not account for this and to me these look mostly like errors.

We can either bring all buildings to the world XY for cleaning purposes or build logic that handles varied building base heights.

Also found this case:

where polysurfaces are near coincident but not quite

Added some logic to tackle self intersecting curves such as above and also for courtyard/atrium conditions:

Logic Addition (Check For Interior Courtyards/Atriums):

Logic Addition (Keep Original Building Base Positions OR Snap To World Origin Z):

Here you go (Resulting cleaned file is only 12mb) :wink::

Model Space (All Buildings Cleaned): (43.9 KB)

20230907_Cleaned_Buildings_Response_01b_Cleaned_Buildings_Only.3dm (12.1 MB)

1 Like

Thank you so much, I tried the script for myself and it works perfectly. I have had this type of issue for several years now, this script will help out a lot. Even the boolean union and mergeallcoplanarsrf workflow is refreshing to know.

1 Like

I’m glad it will help you out, I likely will use it myself!

I’m curious about your source data? Typically I thought extruded buildings such as these are created from OSM polyline building boundaries? The the triangulation through me off as I haven’t seen that before.

Also, being a Sketchup user for over a decade I always ran a keyboard shortcut to merge all coplanar faces and was really happy to find out Rhino had the functionality. It’s invaluable in a rapid iteration/modeling workflow (in my opinion)

1 Like

I’m not sure about the source data, as I was given the model for use for a school project. I wanted to clean it up because of how unclean and messy the buildings were to make good-looking drawings.

I was wondering what your thoughts are on this thread. I wanted to join/merge/blend two surfaces, the canopy surface and the front of a building’s surface to create a connected surface. I wanted to make it in a way that could be parametric, so I could move the building surface freely or add multiple building surfaces to test out the best design possible. Or is this idea easier manually than through Grasshopper? I’ve heard back from others saying it’ll be easier manually, but I’m curious to see if there is a way.

I’ll probably reply over there but one idea is to take your pavilion and extend the curves to meet the building forms, connect those curve ends to the top building face line, fillet the transitions, and then create a surface or patch type surface from those curves.

Also project, project onto, and pull curve come to mind but I’d have to test if I can find the time