3
$\begingroup$

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

$\endgroup$
3
  • $\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
    Commented Sep 7, 2016 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
    Commented Sep 8, 2016 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
    Commented Oct 11, 2016 at 7:36

1 Answer 1

2
$\begingroup$
#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
$\endgroup$
3
  • $\begingroup$ That's a lot easier than building these! $\endgroup$
    – uhoh
    Commented Oct 9, 2016 at 15:05
  • $\begingroup$ I mean these $\endgroup$
    – uhoh
    Commented Oct 9, 2016 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
    Commented Oct 10, 2016 at 14:57

You must log in to answer this question.

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