I'm looking for a way to automatically run the update_length() function after editing the actual curve, this would make my curve_length property always be up to date.
import bpy
obj = bpy.context.object
bpy.types.Object.curve_length = bpy.props.FloatProperty(
name = 'Curve Length',
description = 'Curve Length',
default = 0
)
def calculate_curve_length (obj):
curve_length = obj.data.splines[0].calc_length()
return curve_length
def update_length()
obj.curve_length = calculate_curve_length (obj)
update_length()