1

hi I wrote a simple script to take screenshots, but the frames are not updating in the screenshots i.e all screenshots are the same image (a single frame). I introduced a time delay in case blender having problem updating but the problem is still there

import bpy
import pyautogui
import time
c=1
while c<=50:
    bpy.context.scene.frame_current =c
    time.sleep(2)
    path='D:\\Blender\\script_screenshot\\'+str(c)+'.png'
    pyautogui.screenshot(path)
    c=c+5
Ali
  • 23
  • 6

1 Answers1

1

Blender doesn't update the GUI by default when a script is running. See Update viewport while running script

Add bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) after you change frames to update the GUI.

Also, you can take Blender screenshots with a BPY op like this bpy.ops.screen.screenshot( filepath=path, check_existing=False) so you might not need pyautogui.

import bpy
#import pyautogui
import time
c=1
while c<=50:
    bpy.context.scene.frame_current =c
    bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
    time.sleep(0.5)
    path='C:\\tmp\\script_screenshot\\'+str(c)+'.png'
#    pyautogui.screenshot(path)
    bpy.ops.screen.screenshot( filepath=path, check_existing=False)
    c=c+5

Ron Jensen
  • 3,421
  • 1
  • 9
  • 27