Bounding Box

The Bounding Box is a rectangular box, circumscribed around all vertices of the mesh. Usually, Bounding Box is used for

fast calculations of the physical object’s interaction, for example, collisions.

For each mesh in the scene, the Bounding Box is calculated automatically and recalculated every time the mesh is changed.

We can get the coordinates of all Bounding Box corners for any object through its “bound_box” property, which is an array of the “bpy_prop_array” type with a set of coordinates. Each element of the “bound_box” array, is the array of point coordinates:

The object’s Bounding Box coordinates are in its local coordinate system. To get the global coordinates of the Bounding Box (in the scene coordinate system), we need to multiply its local coordinates by the object’s world matrix.

It should also be in mind that the Bounding Box is calculated for the base object, its coordinates depend, for example, if object modifiers are enabled or not.

To get the final coordinates of the Bounding Box, we need to use the evaluated object. We can get the evaluated object from the base object using the depsgraph:

Now we can get the final coordinates of the Bounding Box:

For example, let’s create an empty in each corner of the Bounding Box of the object. Cycling through the list of the final coordinates of the Bounding Box, add an empty for each of them and set its location equal to the corner coordinates:

The final code:


*.blend and *.py files with the example for my subscribers on Patreon

5 2 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Inline Feedbacks
View all comments