Get Blender X,Y,Z and Bounding Box with script I need to get the x,y,z values of an object as well as the bounding box through a script. So far I have the area and volume with the following code:

bm = bmesh.new()
bm.from_object(bpy.context.object, bpy.context.scene)
area = str(sum(f.calc_area() for f in bm.faces))
volume = str(bm.calc_volume())


I tried something like this for the bounding box:

bb = str(bm.dimensions())


or

bb = bpy.data.objects["test2-2"].dimensions


but neither have worked. As far as the x,y,z values go I'm stumped. Please let me know if you have any suggestions.

Thanks!
To include parenting and drivers, use this for the actual object location / origin:

ob = bpy.context.object

ob.matrix_world.translation # or .to_translation()



You can get the bounding box corners Object.bound_box in object-space and multiply by Object.matrix_world for world-space:

from mathutils import Vector
bbox_corners = [ob.matrix_world * Vector(corner) for corner in ob.bound_box]
# bbox_corners = [ob.matrix_world @ Vector(corner) for corner in ob.bound_box]  # Use this in V2.80+


Note that the bounding box is not axis aligned.