0
$\begingroup$

In object mode, when I press 'N' I get a little box called Transform. At the bottom of this box I can see the X,Y,Z dimensions of my mesh. Is there a way to get these dimensions through the Python script?

Like if I just want the Y dimension (height of object) returned, would I do something like:

bpy.ops.mesh.Transform.dimensions[1]
$\endgroup$
1
$\begingroup$

Some blender basics

The console is a great place to figure stuff out

enter image description here

where C = bpy.context and D = bpy.data for our convenience.

>>> C.object
bpy.data.objects['Cube']

>>> C.object.dimensions
Vector((2.0000009536743164, 2.0000009536743164, 2.0))

>>> C.object.dimensions.y
2.0000009536743164

>>> 

The height of an object in blender is its Z dimension. Blender uses Z up and -Y forward.

The buttons in blender run operators. In code these start with bpy.ops The translate operator for example is bpy.ops.transform.translate()

The python console has autocomplete, hence you can peck around and nut somethings out.

$\endgroup$
  • $\begingroup$ This is perfect, exactly what I was looking for, thank you $\endgroup$ – Forrest Dec 5 '19 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.