var bbox = new BoundingBox();
bbox.Union(new Point3d(1, 1, 1));
bbox.Union(new Point3d(2, 2, 2));
// Expected: bbox.Max = (2,2,2), bbox.Min = (1,1,1)
// But bbox.Min = (0,0,0)
// I know why, but shouldn’t it work differently?
var bbox = new BoundingBox();
bbox.Union(new Point3d(1, 1, 1));
bbox.Union(new Point3d(2, 2, 2));
// Expected: bbox.Max = (2,2,2), bbox.Min = (1,1,1)
// But bbox.Min = (0,0,0)
// I know why, but shouldn’t it work differently?
There are four BoundingBox constructors. All appear to want some kind of argument inside the parentheses.
It looks like if you don’t supply an argument, RhinoCommon automatically adds 0,0,0 as a point and makes the box with that:
import Rhino
bbox=Rhino.Geometry.BoundingBox()
print(bbox.Min,bbox.Max)
bbox.Union(Rhino.Geometry.Point3d(1, 1, 1))
print(bbox.Min,bbox.Max)
bbox.Union(Rhino.Geometry.Point3d(2, 2, 2))
print(bbox.Min,bbox.Max)
However it also appears you can force a non-defined bounding box by using Rhino.Geometry.BoundingBox.Unset
. Then your code will work:
import Rhino
bbox=Rhino.Geometry.BoundingBox.Unset
print(bbox.Min,bbox.Max)
bbox.Union(Rhino.Geometry.Point3d(1, 1, 1))
print(bbox.Min,bbox.Max)
bbox.Union(Rhino.Geometry.Point3d(2, 2, 2))
print(bbox.Min,bbox.Max)