c#_BrepBrep_Boolean Difference Operation

Script is not giving any output.
I have move the curves in Z direction by half of its length, made them into pipes and now trying to perform BrepBrep boolean operation to create a notch in input surface.

I am not able to resolve an error!
where is it going wrong? have Attached script. and image.

I think i know what’s the problem here, at some indexes there is no intersection taking place and it is returning null due to failure. If that’s right how can I solve it>

//x is a list of surfaces, pi1 is a list of pipes and tolr = tolerance value
List be1 = new List();
for(int k = 0; k < x.Count;k++)
for(int l = 0; l < pi1.Count;l++)
Brep bP = Brep.CreateBooleanDifference(x[k], pi1[l], tolr);
if(bP != null && bP.Length > 0 )
else continue;
C = be1;

Are you trying to do some waffle?

If so the pipe (as a tool) is not the way to go.

1 Like

To me this code looks OK,the else continue is a bit useless and can just be deleted, but besides that… Guess the error is elsewhere, maybe you need to post a definition with some geometry…

BTW: How to cut the mustard the proper way:

  1. Is The Force (the dark option) with you? If not abandon ship.
  2. Have in mind that Rhino is a surface modeler … meaning that all sold ops are VERY slow. Avoid waiting for something that any proper solid app does in milliseconds
  3. Create Stripes as Surfaces in U and V. Sample them in 2 Trees.
  4. Assume that UStripes are the future solids in U and the VStripes are the mortise tmp tools. For each VStripe trim the surface (hy half in U) , extend a bit towards the opposite side (better safe than sorry) and thicken the BrepFace at once (Brep.CreateFromOffsetFace) For the distance add some value for the glue, Add to the mortise List.
  5. From each thickened (Brep.CreateFromOffsetFace) stripe in UStripes do the bool diff against the Breps in the mortise List. Or do it one by one. Or be smart and do it VS the things that intersect (way faster). Take care of nulls, bad Karma, oops moments and the likes.
  6. Assume that VStripes are the future solids in V and the UStripes are the mortise tools … blah, blah.


It would be great help if you could guide me through. Find attached GH file with internalised geometry.
Waffel exercise.gh (11.3 KB)

Looking at the images, I get your point pipes may be no be useful. But for instance Geomtery is very simple in my case. So the idea with boolean operations with pipe shall work( Just doing it for the practice).

Thank you Peter, I appreciate taking time for it.
I will follow your code and try to understand if first! its always complicated to understand your code for me(of curse due to my inexperience in c# …haha)

OK, here’s the deal: Try to do it … and if you can’t I’ll post here the real McCoy.

Moral: Long is the path (and hilly).

Not sure, my guess would be that the boolean difference between the surfaces and pipes does not work like that, I am also not 100% sure where you want to go with that.

Either trim the surfaces, or use closed solids.

Btw, all this could probably also be done using native GH components.

1 Like

I understood what you mean.
I want to trim/split the surfaces actually using the pipes, so I shouldn;t be using booleanOperation, I was doing it wrong. I think I need to look for Brep Split method.

Yes, I can do a thing which I am trying to do with grasshopper native components. Since I am learning c#, I am trying to do it in c#.

No you can’t (having the general case in mind).

Just 3 out of too many reasons:

  1. For a nurbs BrepFace acting as a template (holes, trim etc etc) you’ll need torsion free segments (real-life, that is) meaning that the stripes are not continuous … meaning … see 2.
  2. For the connecting stuff (kinda some sort of metal “hinges”) you’ll need Instance definitions otherwise your file size could be huge. Clash issues (with regard hinges) are on the menu as well.
  3. For doing the pieces you’ll need packing solutions. Have in mind the hideous cost of proper marine plywood (a 40mm 1.2 * 2.2m sheet is a 350++E thingy) … meaning that waste material is a no-no.
1 Like