I have a script to run animation which is simulating sewing clothes. Below is a part of my code to add handle and start animation.
def sew(body_name, garment_name, export_body): body_obj = bpy.data.objects[body_name] garment_obj = bpy.data.objects[garment_name] s = bpy.context.scene s.frame_start = 1 s.frame_end = 40 s.frame_current = 1 def stop_playback(scene): if scene.frame_current == 25: bpy.ops.screen.animation_cancel(restore_frame=False) after_sew(garment_name, export_body) bpy.app.handlers.frame_change_post.append(stop_playback) bpy.ops.screen.animation_play()
While intending to run the sewing animation from frame 1 to frame 25, I want to keep the python execution active so it will run
after_sew() when the animation is done. When I run the script inside Blender's TextEditor, it does wait until the animation complete, and the
after_sew() function does run accordingly. However, when I try to run this in background:
blender myblend.blend -b --python sewing.py
The script will compile until this
sew() function, start the animation, but then exit immediately without waiting for the animation reach frame 25, thus
after_sew() will not run.
Is there any way to make python wait until animation done with an UI-less Blender?
I've found other similar thread talking about animation, but they are mostly about rendering with a camera which I don't need. What I only need is to export the sewed cloth at frame 25 using the