How to make a text object show dimensions of an object?
#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) &gt; 0:
        u = "m"
        y = x
    elif x*100 &gt; 0:
        u = "cm"
        y = x*100
    else:
        u = "mm"
        y = x*1000
    return str(y)+" "+u