Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Loose fit BoundingBox

$
0
0

Why am I getting a extended bounding box for a plane surface. I am generating the box for a plane surface. Is there a way to get tight bounding box?
MicrosoftTeams-image (34)
Here is the C# script I am using.

RhinoDoc activeDoc = RhinoDoc.ActiveDoc;
    IEnumerable<RhinoObject> brepObjects1 = activeDoc.Objects.GetObjectList(ObjectType.Brep);
    RhinoObject object1 = brepObjects1.ElementAt(0);
    Brep body = Brep.TryConvertBrep(object1.Geometry);

    Point3d Centroid = body.GetBoundingBox(true).Center;


    List<BoundingBox> boxes = new List<BoundingBox>();
    List<string> points = new List<string>();

    foreach (BrepFace surface in body.Faces)
    {
      List<Point3d> point = new List<Point3d>();
      BoundingBox box = surface.GetBoundingBox(true);
      boxes.Add(box);
      Point3d max = box.Max;
      Point3d min = box.Min;

      Vector3d offset = new Vector3d(Centroid.X, Centroid.Y, Centroid.Z);
      Point3d point1 = Point3d.Subtract(min, offset);
      Point3d point2 = Point3d.Subtract(max, offset);

      points.Add(point1.ToString() + "\n" + point2.ToString());

    }

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles