I am trying to render and save multiple images through python script in blender. I know how to render and save the image through the Blender GUI but I want to do it all through
You will have to do the following. The i
in the second line after the for
loop is the loop index of the file loop.
I have verified that this works while running in the console and also from the command line. Don't forget to remove the objects after you render one file. (The remove command is not given here since it is not generic. Some specific arguments will be needed in that command if that object has links)
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
area.spaces[0].viewport_shade = 'RENDERED'
bpy.context.scene.render.image_settings.file_format='JPEG'
bpy.context.scene.render.filepath = ".pic%0.2d.jpg"%i
bpy.ops.render.render(use_viewport = True, write_still=True)