How to make a text object show dimensions of an object?

I'm working on a way to make a semi-automatic system for visualisizng dimensions

One last thing I need is to make the text boxes automatically contain the wireframe cube's X, Y and Z dimensions (not scale) with units and 2 decimal point precision like this:

2.56 cm 7.2 mm 10 m

• Is your question about how to set the text of a text object, or how to get the dimensions of an mesh object? – JakeD Sep 7 '16 at 15:58
• One way to update text blender.stackexchange.com/a/6973/15543 To display units blender.stackexchange.com/a/1071/15543. – batFINGER Sep 8 '16 at 10:34
• pycoder - my question is about how to get the dimensions, express them in human-readable form and write them automatically to text objects when the "bounding box" object changes dimensions. – unfa Oct 11 '16 at 7:36

#ob is the object you want to measure
#x_ob,y_ob,z_ob are the three text objects
(x,y,z) = ob.dimensions.to_tuple()
x_ob.data.body = str(x)
y_ob.data.body = str(y)
z_ob.data.body = str(z)


If you want to use the metric system, you can add this:

bpy.context.space_data.context = 'SCENE'
bpy.context.scene.system = 'METRIC'


If you want the correct unit you can make this kind of function:

def units(x):
if int(x) > 0:
u = "m"
y = x
elif x*100 > 0:
u = "cm"
y = x*100
else:
u = "mm"
y = x*1000
return str(y)+" "+u

• That's a lot easier than building these! – uhoh Oct 9 '16 at 15:05
• I mean these – uhoh Oct 9 '16 at 15:11
• Ok, but how do I make this script run automatically every time I change the dimensions of the ob? Should I use a driver or what? – unfa Oct 10 '16 at 14:57