BooleanDifference Operation

Hi All,

I am having an issue with Boolean Differences

            beam = beam.CapPlanarHoles(0.01);
            beam = Brep.CreateBooleanDifference(beam, end1Box, 0.001)[0];

            DA.SetData(0, beam);

the beam is a solid, end1Box is a solid

I can return beam and end1Box individually from the code, however, when I run the CreateBooleanDifference it returns it as 1 big Brep.

If I take the 2 Breps individually and is the Solid difference node, it works as expected.


Have I misunderstood or missed something in the code?

import Rhino.Geometry as rg

create two spheres

sphere1 = rg.Sphere(rg.Point3d(0, 0, 0), 5)
sphere2 = rg.Sphere(rg.Point3d(2, 0, 0), 5)

create two breps from the spheres

brep1 = rg.Brep.CreateFromSphere(sphere1)
brep2 = rg.Brep.CreateFromSphere(sphere2)

perform boolean difference

result = rg.Brep.CreateBooleanDifference(brep1, [brep2], 0.001)

output the result

a = result[0]

(It’s an ai generated code try something like this may be it will work, you can use "get geometry"instead of using create from sphere
[ Something like this

import Rhino.Geometry as rg

create two geometry inputs

geo1 = x[0]
geo2 = x[1]

create a Brep representation of the first geometry input

brep1 = rg.Brep.TryConvertBrep(geo1)

create a Brep representation of the second geometry input

brep2 = rg.Brep.TryConvertBrep(geo2)

perform a Boolean difference operation

result = rg.Brep.CreateBooleanDifference(brep1, brep2, 0.001)

output the result

if result: # if the Boolean difference operation was successful
output = result[0] # output the resulting geometry
output = None # if the Boolean difference operation failed, output None

Thanks for the reply. I completely forgot to mention that I am writing a custom node using C#. I don’t think it would make a difference, but thought I’d mention it

Found the solution. Beam had SolidOrientation as Inwards, and the box as outward. Once I flipped the beam, worked as expected

1 Like

Check surface normals. Usually boolean difference ending up as a union can be an inverted set of normals.