1
$\begingroup$

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
$\endgroup$

1 Answer 1

1
$\begingroup$

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
    
$\endgroup$
2
  • $\begingroup$ Thank you very much $\endgroup$ Commented Apr 4, 2021 at 19:47
  • 1
    $\begingroup$ If Ron's answer has solved your issue, please consider to accept the answer @Ali Thanks. See: blender.stackexchange.com/help/someone-answers $\endgroup$ Commented Apr 5, 2021 at 7:44

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.