rhino3dm.BoundingBox

class rhino3dm.BoundingBox
class BoundingBox(min: Point3d, max: Point3d)
class BoundingBox(minX: float, minY: float, minZ: float, maxX: float, maxY: float, maxZ: float)
class BoundingBox(points: collections.abc.Sequence[Point3d])
class BoundingBox(points: collections.abc.Sequence[Point3d], xform: Transform)

Represents the value of two points in a bounding box defined by the two extreme corner points.

This box is therefore aligned to the world X, Y and Z axes.

ClosestPoint(point: Point3d) → Point3d
ClosestPoint(point: Point3d, includeInterior: bool) → Point3d

Finds the closest point on or in the bounding box.

Parameters:
  • point – Sample point.

  • includeInterior – If false, the point is projected onto the boundary faces only, otherwise the interior of the box is also taken into consideration.

Returns:

The point on or in the box that is closest to the sample point.

Contains(point: Point3d) → bool
Contains(point: Point3d, strict: bool) → bool
Contains(box: BoundingBox) → bool
Contains(box: BoundingBox, strict: bool) → bool

Determines whether this bounding box contains another bounding box.

The user can choose how to treat bounding boxes with coincident surfaces.

Parameters:
  • box – Box to test.

  • strict – If true, the box needs to be fully on the inside of the bounding box. I.e. coincident boxes will be considered ‘outside’.

Returns:

true if the box is (strictly) on the inside of this BoundingBox.

Corner(minX: bool, minY: bool, minZ: bool) → Point3d

Gets one of the eight corners of the box.

Parameters:
  • minX – true for the minimum on the X axis; false for the maximum.

  • minY – true for the minimum on the Y axis; false for the maximum.

  • minZ – true for the minimum on the Z axis; false for the maximum.

Returns:

The requested point.

static Decode(jsonObject: dict[str, Any]) → BoundingBox

The object a dict from Encode describes (rhino3dm only).

Parameters:

jsonObject – A dict as Encode returns it.

Encode() → dict[str, Any]

This box as a JSON-compatible dict: {'Min': {'X', 'Y', 'Z'}, 'Max': {...}} (rhino3dm only; inverse: BoundingBox.Decode).

FurthestPoint(point: Point3d) → Point3d

Finds the furthest point on the Box.

Parameters:

point – Sample point.

Returns:

The point on the box that is furthest from the sample point.

GetCorners() → list[Point3d] | None

Gets an array filled with the 8 corner points of this box.

See remarks for the return order.

[0] Min.X, Min.Y, Min.Z

[1] Max.X, Min.Y, Min.Z

[2] Max.X, Max.Y, Min.Z

[3] Min.X, Max.Y, Min.Z

[4] Min.X, Min.Y, Max.Z

[5] Max.X, Min.Y, Max.Z

[6] Max.X, Max.Y, Max.Z

[7] Min.X, Max.Y, Max.Z

Returns:

An array of 8 corners.

GetEdges() → list[Line] | None

Gets an array of the 12 edges of this box.

Returns:

If the bounding box IsValid, the 12 edges; otherwise, null.

Inflate(amount: float) → None
Inflate(xAmount: float, yAmount: float, zAmount: float) → None

Inflate the box with custom amounts in all directions. Inflating with negative amounts may result in decreasing boxes.

InValid boxes can not be inflated.

Parameters:
  • xAmount – Amount (in model units) to inflate this box in the x direction.

  • yAmount – Amount (in model units) to inflate this box in the y direction.

  • zAmount – Amount (in model units) to inflate this box in the z direction.

static Intersection(a: BoundingBox, b: BoundingBox) → BoundingBox

Computes the intersection of two bounding boxes.

The intersection is empty when a and b do not overlap, and when either box is invalid. Invalid boxes are treated as the empty set. Boxes that merely touch do overlap, and produce a valid, degenerate (zero thickness) intersection box.

To test two boxes for overlap without constructing an intersection box, use IsDisjoint.

Parameters:
  • a – A first bounding box.

  • b – A second bounding box.

Returns:

The intersection bounding box, or Unset if the intersection is empty.

IsDegenerate(tolerance: float) → int

Determines whether a bounding box is degenerate (flat) in one or more directions.

Parameters:

tolerance – Distances <= tolerance will be considered to be zero. If tolerance is negative (default), then a scale invariant tolerance is used.

Returns:

0 = box is not degenerate 1 = box is a rectangle (degenerate in one direction). 2 = box is a line (degenerate in two directions). 3 = box is a point (degenerate in three directions) 4 = box is not valid.

IsDisjoint(box: BoundingBox) → bool
IsDisjoint(box: BoundingBox, tolerance: float) → bool

Determines whether this bounding box and another bounding box are disjoint, that is, whether they do not intersect, allowing a tolerance for the comparison.

If either box is invalid, then true is returned.

Parameters:
  • box – Box to test.

  • tolerance – Distance tolerance for the comparison. When tolerance is positive, the boxes are considered to intersect (not disjoint) if the gap between them is less than or equal to tolerance. This is useful as a coarse pre-check when the boxes may be separated by numerical noise but the underlying geometry actually intersects within a working tolerance. When tolerance is 0.0, the result is the same as IsDisjoint(box). When tolerance is negative, the boxes must overlap by more than the absolute value of tolerance to be considered not disjoint.

Returns:

true if this bounding box and box are disjoint.

MakeValid() → bool

Ensures that the box is defined in an increasing fashion along X, Y and Z axes. If the Min or Max points are unset, this function will not change the box.

Returns:

true if the box was made valid, false if the box could not be made valid.

MaximumDistanceTo(testPoint: Point3d) → float

Finds the largest distance between this bounding box and a test point.

Parameters:

testPoint – A point to test.

Returns:

The maximum distance.

MinimumDistanceTo(testPoint: Point3d) → float

Finds the shortest distance between this bounding box and a test point.

Parameters:

testPoint – A point to test.

Returns:

The minimum distance.

PointAt(tx: float, ty: float, tz: float) → Point3d

Evaluates the bounding box with normalized parameters.

The box has idealized side length of 1x1x1.

Parameters:
  • tx – Normalized (between 0 and 1 is inside the box) parameter along the X direction.

  • ty – Normalized (between 0 and 1 is inside the box) parameter along the Y direction.

  • tz – Normalized (between 0 and 1 is inside the box) parameter along the Z direction.

Returns:

The point at the {tx, ty, tz} parameters.

ToBrep() → Brep

Constructs a Brep representation of this bounding box.

Returns:

If this operation is successful, a Brep representation of this box; otherwise null.

ToString() → str

Constructs the string representation of this aligned bounding box.

Returns:

Text.

Transform(xform: Transform) → bool

Updates this bounding box to be the smallest axis aligned bounding box that contains the transformed result of its 8 original corner points.

Parameters:

xform – A transform.

Returns:

true if this operation is successful; otherwise false.

property Area: float

Gets the area of this BoundingBox.

property Center: Point3d

Gets the point in the center of the bounding box.

property Diagonal: Vector3d

Gets the diagonal vector of this BoundingBox. The diagonal connects the Min and Max points.

Empty: BoundingBox = Ellipsis

object, /) -> BoundingBox

Type:

(arg

property IsValid: bool

Gets a value that indicates whether or not this bounding box is valid. Empty boxes are not valid, and neither are boxes with unset points.

property Max: Point3d

Gets or sets the point in the maximal corner.

property Min: Point3d

Gets or sets the point in the minimal corner.

Union: Any = Ellipsis

Both forms (static and instance):

BoundingBox.Union(a, b): Returns a new BoundingBox that represents the union of boxes a and b. BoundingBox.Union(box, point): Returns a new BoundingBox that represents the union of a bounding box and a point. boundingBox.Union(other): Updates this BoundingBox to represent the union of itself and another box. boundingBox.Union(point): Updates this BoundingBox to represent the union of itself and a point.

Unset: BoundingBox = Ellipsis

object, /) -> BoundingBox

Type:

(arg

property Volume: float

Gets the volume of this BoundingBox.