C# Boolean difference between a surface and a solid


Is it possible to obtain a Boolean difference between a surface and a solid, where the solid is the cutter (i.e. create a hole in a surface by a cylindrical solid passing through it)?

Thank you!


Hi Christina,

If you create a surface and a solid, in Rhino, and use the BooleanDifference command, do you get the results you want?

– Dale

Hi Dale,

Unfortunately, if I choose the surface as the object to subtract from and the solid(the cylinder) the object to subtract with, then the result is a strange mix of the two (expected result is just a cutout in the surface).
For now I divided the code into step by step operations: splitting, selecting, deleting, but it would have been nice if it would work in one go, as when both objects are solids.
Thank you and any other idea is appreciated!

Running into the same issue. I don’t think the behavior shown (per the screenshots) is correct. I interpret boolean difference as a subtraction of one thing from another. I would have expected a hole…

how about splitting the surface using the cylinder and deleting the enclosed surface?

I had the same problem in code with rhinocommon.

I believe the normals of cylinder are flipped.
I remember @Dale showed a line of code that checks if closed brep orientation is inward, if yes I had to flip brep. Then the boolean difference

// The profile curve is a degree=1 curve. Thus, the extruded surface will
// have kinks. Because kinked surface can cause problems down stream, Rhino
// always splits kinked surfaces when adding Breps to the document. Since
// we are not adding this Brep to the document, lets split the kinked
// surfaces ourself.

brep.Faces.SplitKinkyFaces(RhinoMath.DefaultAngleTolerance, true);

// The profile curve, created by the input points, is oriented clockwise.
// Thus when the profile is extruded, the resulting surface will have its
// normals pointed inwards. So lets check the orientation and, if inwards,
// flip the face normals.

 if (BrepSolidOrientation.Inward == brep.SolidOrientation)