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
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.
http://4.rhino3d.com/5/rhinocommon/html/M_Rhino_Geometry_Brep_Split.htm
http://4.rhino3d.com/5/rhinocommon/html/M_Rhino_Geometry_Brep_Split_1.htm
http://4.rhino3d.com/5/rhinocommon/html/M_Rhino_Geometry_Brep_Trim.htm
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)
{
continue;
}
var selectionPoint = obj.SelectionPoint();
var splittedBreps = brepToTrim.Split(CuttingObject, Tolerance);
foreach (var brep in splittedBreps)
{
if (!brep.IsPointInside(selectionPoint, Tolerance, true))
{
brepList.Add(brep);
}
}
}
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:
I really cannot understand what I am doing wrong.
Here is a simple sample that you an reference.
https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsTrimSurface.cs
Thanks a lot! That really helped!