I can update a text curve object when I change the frame and it doesn't create multiple objects but how can I do the same with a mesh object.
Code:
import bpy
scene = bpy.context.scene
font_curve = bpy.data.curves.new(type="FONT",name="Font Curve")
font_curve.body = 'Current Frame: ' + str(scene.frame_current)
font_obj = bpy.data.objects.new("Font Object", font_curve)
scene.collection.objects.link(font_obj)
def recalculate_obj(scene):
font_curve.body = 'Current Frame: ' + str(scene.frame_current)
def register():
bpy.app.handlers.frame_change_post.append(recalculate_obj)
def unregister():
bpy.app.handlers.frame_change_post.remove(recalculate_obj)
register()
It doesn't create multiple Font objects (this is what I want it just replaces the last one)
But when I try and do it with a mesh object I run into problems due to the "_add"
import bpy
scene = bpy.context.scene
font_curve = bpy.data.curves.new(type="FONT",name="Font Curve")
font_curve.body = 'Current Frame: ' + str(scene.frame_current)
font_obj = bpy.data.objects.new("Font Object", font_curve)
scene.collection.objects.link(font_obj)
cyl_obj = bpy.ops.mesh.primitive_cylinder_add(radius = 1)
def recalculate_obj(scene):
font_curve.body = 'Current Frame: ' + str(scene.frame_current)
cyl_obj = bpy.ops.mesh.primitive_cylinder_add(radius = scene.frame_current)
def register():
bpy.app.handlers.frame_change_post.append(recalculate_obj)
def unregister():
bpy.app.handlers.frame_change_post.remove(recalculate_obj)
register()
My goal is to replace the line bpy.ops.mesh.primitive_cylinder_add command with the python line below but have the a, b, c and d variables in the x_eq, y_eq, z_eq animated with out creating multiple objects.
cyl_obj = bpy.ops.mesh.primitive_xyz_function_surface(x_eq = "a+v", y_eq = "b*sin(2*pi*u+c)", z_eq = "cos(2*pi*u)/d")







will cause the memory to increase every time you scub the time line(and thememory usage will NOT go down) also some other strange things happen when switching between edit mode and object mode. I found some useful python code and connected it to Animation Nodes and will post it as a workaround / one of the correct ways to do this. – Rick T Jul 23 '20 at 02:47