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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.