3
$\begingroup$

I am getting started with the Blender Python API and there is something I do not understand. Lets say I have an object called "myObject" and I wanted to get its dimensions, then I type

bpy.data.objects["myObject"].dimensions

in the python console and get the result. The API http://www.blender.org/documentation/blender_python_api_2_71_release/bpy.types.Object.html#bpy.types.Object states, that an object also has a bound_box. But if I type

bpy.data.objects["myObject"].bound_box

simply the command I typed is returned! Why is that and how could I have known from the doc of the API? Also, when I type

bpy.data.objects["myObject"].show_bounds

it only returns "false". Why? If I go to the object properties panel and click "Bound" the bounding box is drawn. Why does that work and doing the same (?) via the console does not?

Thank you!

$\endgroup$
1
  • $\begingroup$ Ah, I figured out that one simply has to set show_bounds to True to be able to see the bounding box of an object. However, I have still not figured out how to see the values of the bounding box $\endgroup$ Jul 15, 2014 at 11:50

1 Answer 1

4
$\begingroup$

Object.bound_box does not contain mathutils-types like Matrix or Vector, it's a plain property array of float[3] which has no representation format like other types do.

You need to iterate over all elements and print them, e.g.:

for b in bpy.context.object.bound_box:
    print(b[:])

# (-1.0, -1.0, -1.0)
# (-1.0, -1.0, 1.0)
# (-1.0, 1.0, 1.0)
# (-1.0, 1.0, -1.0)
# (1.0, -1.0, -1.0)
# (1.0, -1.0, 1.0)
# (1.0, 1.0, 1.0)
# (1.0, 1.0, -1.0)

Or make a list of Vector objects:

[Vector(b) for b in bpy.context.object.bound_box]
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .