Scaling a box to fit a mesh?

same principle applies. For example, here is the function that scales the box to a child component.

Atention: the calculation for SetLocation are done considering the pivot of the meshes are at their base and at their center, like in the default chair, couch, door, …
So if the pivot is at the center of the mesh, then no calculations are required, and you can connect the box bounds origin directly to new location.