0

I am using Python script to do off-screen CLOTH simulation. But, after I executed bpy.ops.screen.animation_play(), the current frame is blocked at frame 1.

C.scene.frame_start = 1
C.scene.frame_end = 50
C.scene.frame_set(1)

def stop_playback(scene): if scene.frame_current == 10: bpy.ops.screen.animation_cancel(restore_frame=False)

bpy.app.handlers.frame_change_pre.append(stop_playback) #start animation bpy.ops.screen.animation_play()

time.sleep(2) print(C.screen.is_animation_playing) # True print(C.scene.frame_current) # 1 time.sleep(10) print(C.screen.is_animation_playing) # True print(C.scene.frame_current) # 1 print('tag')

  • 2
    Consider a modal timer operator. The expectation above is the context is being updated by play operator and that it will be reflected by sleeping and printing, however not the case, you are seeing the context as set in script to frame 1. Related https://blender.stackexchange.com/questions/95335/time-delay-when-selecting-objects-in-a-python-script https://blender.stackexchange.com/questions/131913/need-help-moving-a-set-of-cubes-from-one-end-to-the-other-on-x-axis-with-python – batFINGER Jun 06 '21 at 14:39
  • 1
    btw can bake a cloth sim eg https://blender.stackexchange.com/questions/6249/setting-the-context-for-cloth-bake without playing animation. ... – batFINGER Jun 06 '21 at 14:52

0 Answers0