Solid difference fails where Rhino Boolean difference doesn't

I’m trying to extract the internal volume of a 3D print model.
To do so I use the boolean difference subtracting the printing volume from a “bounding box volume”.

When I using Boolean Difference in Rhino, this approach works correctly. However if the same solids/breps passed into “Solid difference” in GH, the subtraction fails and it returns just the starting volume.
I think that if you look at the attached file it makes much more sense than trying to explain it here.

I also tried using a python script that uses Rhino’s Boolean difference, but with no luck.

import Rhino
import scriptcontext as sc

sc.doc = Rhino.RhinoDoc.ActiveDoc
tolerance = sc.doc.ModelAbsoluteTolerance

R = None

if brep_A and brep_B:
    print("Attempting Boolean Difference...")
    print("Using Tolerance: {}".format(tolerance))

    try:
        R = Rhino.Geometry.Brep.CreateBooleanDifference(brep_A, brep_B, tolerance)
    except Exception as e:
        print("An error occurred during Boolean Difference: {}".format(e))
else:
    print("Input brep_A or brep_B is missing.")

How is it possible that the two commands return different outputs? Can I use the “plain” rhino boolean difference inside a grasshopper script?

Bonus question: do you have better ideas to extract the internal volume of this solid? Note that the solid is missing the base, so my strategy was to shift the bounding box one millimetre up so that the base of the model was cutting outside the base of the box, allowing the internal volume to be disconnected from the outside remainder that I can then delete.

GH boolean diff test.gh (11.9 MB)

looks like you original geometry (when opened in gh R8) is seen as Open Brep, I guess some unwelded seams, because deconstructing and joining it solves the issue?

GH boolean diff test_inno.gh (8.7 MB)

don’t well understand how you get an open brep as result of a Boolean operation in Rhino

1 Like

@inno Nice + Fast deduction. Love it

Looks like the your code starts with an ‘Open Brep’ in both R7 and R8?

R7:

R8:

1 Like

looks like you original geometry (when opened in gh R8) is seen as Open Brep, I guess some unwelded seams, because deconstructing and joining it solves the issue?

Thank you very much!

What I don’t understand is that in rhino the same geometry is described as “closed”. I did check there, but did not think of double checking in GH as well.

Is there an explanation for this or just a fluke?

I guess if you look at what the command line says, it got trimmed out in the screenshot, it might say open polysurface:

like on my machine:

“closed non-manifold polysurface” is a different state than “closed polysurface” :slight_smile: a non-manifold polysurface is a polysurface where one or more edges are shared by more than two surfaces, making it impossible -at that moment- to clearly define an inside and an outside

you can use the Rhino command ShowEdges and chose “non-manifoldable” to highlight the culprit, in this case the reason is these two box-shaped solids with an edge in common (red hatch is a clipping plane cutout I placed there to get better visibility)

looks like that same one edge (actually also its tiny continuation on the backside) is shared by 4 different surfaces, and is causing the problem

exploding and joining at once the whole polysurface solves it in both Rhino and in gh

note that for a given polysurface, joining it in different batches -as opposite of joining it all in one shot- might yeld different (and sometimes unexpected) results

2 Likes