8

To be clear i want a script, which produces what i am describing below. I want to iterate through all the cameras in my scene where each one renderes an image. I can do this manually by rendering with active camera, then set another camera to active, and then render again.

I have five cameras in my scene and i am going to be using this scene a lot. in reality the question might be more about setting a camera to active with script.

Artmole
  • 691
  • 1
  • 8
  • 14
  • 1
    might be easier to control: http://blender.stackexchange.com/questions/23121/is-it-possible-to-set-the-output-name-based-on-the-current-timeline-marker/23145#23145 – p2or Sep 07 '15 at 19:03

2 Answers2

10

You might want to edit the os.path.join to get an OS independent tmp directory or set something else.

import bpy
import os

scene = bpy.context.scene

for ob in scene.objects:
    if ob.type == 'CAMERA':
        bpy.context.scene.camera = ob
        print('Set camera %s' % ob.name )
        file = os.path.join("C:/tmp", ob.name )
        bpy.context.scene.render.filepath = file
        bpy.ops.render.render( write_still=True )
stacker
  • 38,549
  • 31
  • 141
  • 243
  • I am not a python genius, why would i need to do so? – Artmole Apr 24 '14 at 21:53
  • @Artmole the drive letter C: wouldn't work on Linux and MacOs or you want another output folder. The rest is straight forward loop over all objects in the scene, check whether the object is a camera if so set it as camera, setup the filepath where the render should be stored and write the render to a file with the name of the camera. – stacker Apr 25 '14 at 06:13
4

If it's a still, you could make it into an animation where the only thing that changes is the active camera, and render it as an animation (see How can I make a camera the active one? for how to animate the active camera property)

linuxhackerman
  • 743
  • 1
  • 4
  • 6