Example Trim surface

Hi, has anyone an example command for RhinoCommon that trims a surface with another surface? I searched in the wiki and the github repo but did not find anything.

Thanks a lot

Unless you are working with a closed cutter, you are probably better of using Split, and then decide which parts to keep, based on size, location, etc.



I tried using split but I got an empty array out of the call. My code is:

 var brepList = new List<Brep>();
 foreach (var obj in ObjectToTrim)
   var brepToTrim = obj.Brep();
   if (brepToTrim == null)

   var selectionPoint = obj.SelectionPoint();
   var splittedBreps = brepToTrim.Split(CuttingObject, Tolerance);
   foreach (var brep in splittedBreps)
     if (!brep.IsPointInside(selectionPoint, Tolerance, true))
 return brepList.ToArray();

and at the end, even if the two breps are clearly intersecting, I got an empty list.

I think your method of selecting the remaining parts not correct. Because Brep.IsPointInside only makes sense if the Brep is closed.
Why not perform a distance test with Brep.ClosestPoint. If the distance is larger than the tolerance, that part should be disregarded.

I updated it using ClosestPoint but still, using the debugger to step through the code gives me splittedBreps.Count == 0 for every surface I select. In this context:

  • ObjectToTrim is a list of ObjRef
  • CuttingObject is an array of Brep
  • Tolerance is the absolute tolerance taken from RhinoApp

I really cannot understand what I am doing wrong.

Here is a simple sample that you an reference.


Thanks a lot! That really helped!