BrepFace in C# and how to get its BoundingBox correctly

Hi,

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


The ones I get:

Code:

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++)
      {
        temp.Faces[j].ShrinkFace(BrepFace.ShrinkDisableSide.ShrinkAllSides);
        boxes.Add(temp.Faces[j].GetBoundingBox(true));
        sectionTree.Add(temp.Faces[j]);
      }
    }
    Sec = sectionTree;

    Boxes = boxes;
  }

Thanks everybody!

File:20210412_GetBBox.gh (24.2 KB)

Hello!
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) Brep_ToBBox_EntryLevel_V1.gh (7.3 KB)

2 Likes

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