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

semi-automatic dimensions visualisation system

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

  • $\begingroup$ Is your question about how to set the text of a text object, or how to get the dimensions of an mesh object? $\endgroup$ – JakeD Sep 7 '16 at 15:58
  • 1
    $\begingroup$ One way to update text blender.stackexchange.com/a/6973/15543 To display units blender.stackexchange.com/a/1071/15543. $\endgroup$ – batFINGER Sep 8 '16 at 10:34
  • $\begingroup$ 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. $\endgroup$ – 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
        u = "mm"
        y = x*1000
    return str(y)+" "+u
| improve this answer | |
  • $\begingroup$ That's a lot easier than building these! $\endgroup$ – uhoh Oct 9 '16 at 15:05
  • $\begingroup$ I mean these $\endgroup$ – uhoh Oct 9 '16 at 15:11
  • $\begingroup$ 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? $\endgroup$ – unfa Oct 10 '16 at 14:57

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.