8
$\begingroup$

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.

$\endgroup$
1

2 Answers 2

10
$\begingroup$

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 )
$\endgroup$
2
  • $\begingroup$ I am not a python genius, why would i need to do so? $\endgroup$
    – Artmole
    Commented Apr 24, 2014 at 21:53
  • $\begingroup$ @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. $\endgroup$
    – stacker
    Commented Apr 25, 2014 at 6:13
4
$\begingroup$

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)

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .