I am using this script to render animations because of this issue. It was doing it's job in older blender but now it works well only until I switch viewport shade to rendered. Then after few frames saved I get:
AttributeError: Writing to ID classes in this context is not allowed: Scene, Scene datablock, error setting Scene.frame_current
Btw I would like also to ask is there a way to capture viewport content or rendered border only?
render_time = 3
import bpy, os, time, threading
bpy.context.scene.frame_current=bpy.context.scene.frame_start
class ScriptThread (threading.Thread):
def init(self, threadID, name):
threading.Thread.init(self)
self.threadID = threadID
self.name = name
def run(self):
is_running = True
tick = time.time()
while is_running is True:
if time.time() >= tick+render_time:
tick = time.time()
time.sleep(render_time)
if bpy.context.scene.frame_current >= bpy.context.scene.frame_end:
is_running = False
else:
os.system('mkdir render')
path='render/'+str(bpy.context.scene.frame_current)+'.jpg'
os.system('import -window root '+path) # linux
os.system('nircmd.exe savescreenshot '+path) # win
bpy.context.scene.frame_current+=1
else:
continue
thread = ScriptThread(1, "thread")
thread.start()
bpy.ops.screen.screenshot(filepath=somefilepath)
give you the result you are after? Recommend usingscene.frame_set(frame)
to set frame. $\endgroup$RuntimeError: Operator bpy.ops.screen.screenshot.poll() failed, context is incorrect
.scene.frame_set(frame)
fixed theAttributeError
but does not restarts viewport render, it keeps sampling the first frame. $\endgroup$