I am trying to write code to align an object to another. To do so, I calculate the objects' bounding boxes like so:
bbox_a = [Vector(bbvert) @ mesh_object_a.matrix_world for bbvert in mesh_object_a.bound_box]
bbox_b = [Vector(bbvert) @ mesh_object_b.matrix_world for bbvert in mesh_object_b.bound_box]
then compare the min or max along the chosen axis, and move the location of the second object accordingly.
However I've noticed that, even if object_b has a location of
<Vector (-4.0000, 0.0000, 0.0000)>
bbox_b is
[
Vector((-1.4142135381698608, 0.0, -1.0)), Vector((-1.4142135381698608, 0.0, 1.0)),
Vector((0.0, 1.4142135381698608, 1.0)), Vector((0.0, 1.4142135381698608, -1.0)),
Vector((0.0, -1.4142135381698608, -1.0)), Vector((0.0, -1.4142135381698608, 1.0)),
Vector((1.4142135381698608, 0.0, 1.0)), Vector((1.4142135381698608, 0.0, -1.0))
]
i.e.: it looks like it has ignored location.
Did I get it right? do I have to apply location on top of matrix_world in order to find out the actual bounding box of the object? and (to future-proof the question) is it so for all other transforms too?
matrix @ vector, not the other way around – Gorgious Aug 02 '21 at 07:54vector @ matrixthing from https://blender.stackexchange.com/questions/88914/how-to-get-3d-vertex-bounding-box-around-the-object-in-python – simone Aug 02 '21 at 08:44