This script is just a rough version of something that I would like to do better, which I slapped together because I wanted to be able to take stills from multiple directions without futzing around with moving or activating cameras and remembering to save the images each time . . .
I’d like to add a GUI configuration and an option to (re)load the images into the UV editor so you can use it to automatically update a bunch of security camera monitors or something like that (which was actually why I thought of this script in the first place, because it goes with the idea I might use if I do the F1-contest-thingie . . . )
To use out of box: name camera objects AC.whatever and run the script.
Also, is there any other way to get at “render” category scripts than the menu on the Scripts window? You’d think they’d show up on the main Render menu on the default menu thingie.
Add: I found a little buglet while testing thing. If you happen to have your output set to Quicktime, it will save Jpeg files but use .tga extentions for the filenames … Might just be a problem when rendering stills and haveing a movie format set.
[FONT=monospace]#!BPY
# """
# Name: 'Autocams'
# Blender: 242
# Group: 'Render'
# Tooltip: 'Render from a set of tagged cameras to a set of images.'
# """
__author__ = "Star Weaver"
__version__ = "0.25"
__email__ = "[email protected]"
import Blender
from Blender import *
# Check all scenes for tagged cameras, or just current
ALLSCENES = True
# Cameras start with NAME_PREFIX followed by NAME_SEP
# Followed by IMAGE_NAME, e.g. "AC.Foo Camera" becomes "Foo Camera.fif"
NAME_PREFIX = "AC"
NAME_SEP = "."
# Or [MyBlendFile - ][MySceneName - ]Foo Camera.fif
# FIF being the Foo Image Format ...
USE_FILE = True
USE_SCENE = True
FILE_SEP = " - "
def RenderCams(scene):
oldscene = Blender.Scene.GetCurrent()
scene.makeCurrent()
oldcamera = scene.getCurrentCamera()
for child in scene.getChildren():
if child.getType() == "Camera":
camera = child
parts = camera.getName().split(NAME_SEP, 1)
if len(parts) == 2:
prefix, suffix = parts
if prefix == NAME_PREFIX:
scene.setCurrentCamera(camera)
context = scene.getRenderingContext()
context.render()
savename = suffix
if USE_SCENE:
savename = scene.getName() + FILE_SEP + savename
if USE_FILE:
fname = Get("filename")
fname, xxx = sys.splitext(sys.basename(fname))
savename = fname + FILE_SEP + savename
context.saveRenderedImage(savename)
if oldcamera:
scene.setCurrentCamera(oldcamera)
oldscene.makeCurrent()
def main():
if ALLSCENES:
for scene in Scene.Get():
RenderCams(scene)
else:
RenderCams(Scene.GetCurrent())
main()