Display length of object to render, dynamically I have an object that is a line that fallows the animation path of a bone. Is there a way to display the length of the arm in text (that can be rendered) that changes the numbers as the arm stretches?

edit.

I tired this:

import bpy

def distance(p1, p2):
    return sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2+ (p1[2]-p2[2])**2)

def update_size(scene):
    point1 = scene.objects['Vert.000'].location
    point2 = scene.objects['Vert.001'].location
    point3 = scene.objects['Vert.002'].location
    len1 = distance(point1, point3)
    len2 = distance(point2, point3)
    scene.objects['Length1'].data.body = '{:.3f}'.format(len1)
    scene.objects['Length2'].data.body = '{:.3f}'.format(len2)
    scene.objects['LengthTotal'].data.body = '{:.3f}'.format(len1 + len2)

bpy.app.handlers.frame_change_pre.append(update_size)


But it does not seem to work when run from the text editor, and when copy pasted and run in console, only updates the first frame.
We can use a frame change handler to alter the text objects content before each frame during playback.

import bpy

def distance(p1, p2):
    return sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2+ (p1[2]-p2[2])**2)

def update_size(scene):
    point1 = scene.objects['Empty.001'].location
    point2 = scene.objects['Empty.002'].location
    scene.objects['Text'].data.body = '{:.3f}'.format(distance(point1, point2))

bpy.app.handlers.frame_change_pre.append(update_size)

# to disable
# bpy.app.handlers.frame_change_pre.remove(update_size)


Instead of using distance between two points you may prefer to add the length of the pose bones between shoulder and hand.

format(scene.objects['rig'].pose.bones['upper_arm.L'].length +
        scene.objects['rig'].pose.bones['forearm.L'].length)