Some kind of way I need to be able to update another object whenever the length of a curve changes (in edit mode by moving the curve’s control points)
I can get the length of the curved updated in real time in a panel, but I can’t seem to translate that into affecting other objects. Does anyone know how to do this?
Thanks. This looks promising, but I cannot figure out how to get the active curve object into that function (do_things_with_curve_length). This is what I tried, but it tells me “Scene” has no attribute ‘object’
from bpy.app.handlers import persistent
def do_things_with_curve_length(context):
if context.object is not None and context.object.type == 'CURVE':
print(context.object.name)
bpy.app.handlers.depsgraph_update_post.append(do_things_with_curve_length)
I got it! I just needed to start with bpy. Thanks!!!
from bpy.app.handlers import persistent
@persistent
def do_things_with_curve_length(scene):
obj = bpy.context.object
if obj is not None and obj.type == 'CURVE':
print(bpy.data.curves[obj.data.name].splines[0].calc_length())
bpy.app.handlers.depsgraph_update_post.append(do_things_with_curve_length)