rendering and saving images through Blender python

后端 未结 3 968
囚心锁ツ
囚心锁ツ 2021-01-30 13:38

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

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-30 14:39

    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)
    

提交回复
热议问题