Using Brep.CreateBoolean.... operations

Hello everyone,

i got issues using the boolean operations of the Brep class.
Even though I know that two breps do intersect the CreateBooleanSplit method returns an empty array. If I understand correctly this means that the split was successfull, but why do I get no results then?

This is the code i wrote: (all Breps are solid and manifold in this example)

//Extrude shape along line.
Plane linePlane = new Plane(line.From, Vector3d.CrossProduct(line.Direction, plane.ZAxis), plane.ZAxis);
Curve orientedShape = shape.DuplicateCurve();
orientedShape.Transform(Transform.PlaneToPlane(Plane.WorldXY, linePlane));

Brep brep = Brep.CreateFromSweep(line.ToNurbsCurve(), orientedShape, true, tolerance)[0];
brep.Faces.SplitKinkyFaces(); //fix 4-sided surface for boolean.
brep = brep.CapPlanarHoles(tolerance); //sweep doesn't do it!

//Move brep for boolean opperations.
brep.Transform(Transform.Translation(intersectionVector));
brep = brep.DuplicateBrep(); //fix brep transform for boolean.
                
for (int i = 0; i < placedBreps.Count; i++)
{
    Curve[] intersectionCurves;
    Point3d[] intersectionPoints;
    if(Intersection.BrepBrep(brep, placedBreps[i], tolerance, out intersectionCurves, out intersectionPoints))
    {
         Brep[] splitResults = Brep.CreateBooleanSplit(brep, placedBreps[i], tolerance);
         brep = splitResults[0];
         placedBreps[i] = splitResults[1];
    }
}

Hopefully someone knows how to use these methods!
Best regards,
Frezap

Hi @frezap,

We are going the code to a fully working sample, that we can run here, if we’re going to be of much help.

Thanks,

– Dale

Hi Dale!

Thanks for answering to my question!

I’ll attach the files needed to reproduce this below.

Thanks in advance for looking into this!

Frezap

2DBoardWall.cs (7.9 KB)
BooleanProblemDemo.gh (5.6 KB)
I hope i didnt forget anything.

Hi @frezap,

I’m sorry, but none of this really helps me. What I need is some that I can run, here, do I can reproduce what you are seeing. An although the code snippet is great, I cannot run it without building my one plug-in. And I cannot open the GH file because I don’t have your component.

Perhaps you can throw this in to a C# component?

– Dale

One thing that at least needs to be added to your code, is that you need to check solid orientation after you capping the brep, the wrong orientation usually returns bad boolean results or null.

Brep.SolidOrientation . If it’s normals are pointed inward, use Brep.Flip to flip the orientation.

1 Like