Blender Python - Get Scene Bounds

Print scene bounds in blender python.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import bpy
from mathutils import Vector

meshes = [o for o in bpy.data.objects if o.type == 'MESH']

# get the minimum coordinate in scene
minV = Vector((min([min([co[0] for co in m.bound_box]) for m in meshes]),
min([min([co[1] for co in m.bound_box]) for m in meshes]),
min([min([co[2] for co in m.bound_box]) for m in meshes])))

maxV = Vector((max([max([co[0] for co in m.bound_box]) for m in meshes]),
max([max([co[1] for co in m.bound_box]) for m in meshes]),
max([max([co[2] for co in m.bound_box]) for m in meshes])))

print(minV, maxV)