BrepFace in C# and how to get its BoundingBox correctly


I am struggling with getting the correct BoundingBox in C#.
The expected one:

The ones I get:


private void RunScript(Brep brep, List<Plane> planes, ref object Sec, ref object Boxes)
    var sectionTree = new DataTree<BrepFace>();
    var boxes = new DataTree<BoundingBox>();

    double tol = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
    for (int i = 0; i < planes.Count; i++)
      Curve[] crvs; Point3d[] pts;
      Rhino.Geometry.Intersect.Intersection.BrepPlane(brep, planes[i], tol, out crvs, out pts);

      Brep temp = brep.Faces[0].Split(crvs, tol);
      for (int j = 0; j < temp.Faces.Count; j++)
    Sec = sectionTree;

    Boxes = boxes;

Thanks everybody! (24.2 KB)

How about DuplicateFace?

thanks a lot @11159 !

BTW: Is always handy a way to control the Box orientation as well.

Brep_ToBBox_EntryLevel_V1.3dm (211.3 KB) (7.3 KB)


Given the opportunity … the usual challenge for the very brave: Given a GeometryBase List of things do the fastest smallest engulfing Box.

First prize: 12 cans of the finest sardines known to man (Da Morgada) in pure mineral oil (15W/40 - what else?).

May the Force … blah, blah.

1 Like