Failing boundingbox

Attacked is a simple Rhino 7 plugin that pulls an accurate bounding box from a Surface object.
The resulting bounding box is way bigger than the original object.

We are trying to figure out why this is failing, and if there is anything we can do to fix the problem?

The non accurate bounding box is much closer, but we need the accurate bounding box size.
Also this code was original written in Rhino 5 , and worked correctly there.

geoTest.zip (66 KB)
image

Hi @gsjefferyes,

Try this:

var id = doc.Objects.AddSurface(s);
var rh_obj = doc.Objects.FindId(id);
if (null != rh_obj)
{
  if (RhinoObject.GetTightBoundingBox(new[] { rh_obj }, Plane.WorldXY, out var bbox))
    doc.Objects.AddBrep(bbox.ToBrep());
}

– Dale