C# Brep Split

Hi,
Could you please help me solve the Brep Split in C#, when I use the example bellow I get 2 clones of the object I want to split, plus the original.
All I want to achieve is a regular split.

Thank you!

{
            ///This is for testing splitting of surfaces
 
            ObjRef srfRef;
            Result result = RhinoGet.GetOneObject("Pick surface to split", false, ObjectType.Surface, out srfRef);
            if (result != Result.Success)
            {
                MessageBox.Show("Couldn't pick surface to split");
                return;
            }
            var srfBrep = srfRef.Brep();
 
            ObjRef splitRef;
            result = RhinoGet.GetOneObject("Pick splitter", false, ObjectType.Surface, out splitRef);
            if (result != Result.Success)
            {
                MessageBox.Show("Couldn't pick splitter");
                return;
            }
            var splitBrep = splitRef.Brep();
            splitBrep.Flip();
 
            var breps = srfBrep.Split(splitBrep, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance);
 
            foreach (var brep in breps)
                foreach (var bsurf in brep.Surfaces)
                    Rhino.RhinoDoc.ActiveDoc.Objects.Add(bsurf);
        }

Hi Cristiane,

In order to add the brep with the trimming information created by split, you will need to add the brep and not the underlying untrimmed surfaces (brep.Surface). Iā€™m not familiar enough with C# but the pseudo code I think should be:

foreach( var brep in breps):
    Rhino.RhinoDoc.ActiveDoc.Objects.AddBrep(brep)

HTH
-Willem

It works!

Thank you very much for your help!

Cristina

1 Like