NOTE: I wrote this tutorial without debugging it because my blender computer is rendering (using this method).
BY TOMORROW i will have debugged it, but be patient, or ask, if it doesn’t work the first time.
(yay, sago smilies!)
Python- rendering multiple frame batches.
Using the method I will describe, you can render several separate batches of frames over several scenes. This means you can ready several animations to render before going on vacation- or even overnight- and run the script to render them all.
you have three cameras rendering an animated model from different views. According to your calculations they will take about 2 hours to render each. It’s 11:00 pm, and you don’t want to get up at 1:00 and 3:00 am to change camera and start rendering the next batch. Here’s how you can set it up to do each in turn with a script.
ok, here’s how it works. Split the window and open it to the blender text editor.
Right-click -> add new.
first a little important syntax stuff, a # sign comments out a line.
this line will be ignored by the python interpreter
this one won’t
this line will also be ignored.
the rest of this tutorial will be written as a script, you could
copy-paste it into blender and it’d work, but you wouldn’t learn
first, we need to get the data from blender, we use the import
now that we have the data, we’ll make a function (mini program that can be called)
that will animate a frame batch
def anim(frames, camname, scn = None):
‘’'This function renders frame batches.
This triple-quoted section is a doc-string, the code ignores it. Note: to call the function you'd use: anim([1,61], 'camera1', 'myscene') The frames variable is a list containing start and end frame. The camera name variable is the name of the camera to render from. The scn variable is the scene name, note is says ' = None ', this is a default, meaning that if you just use: anim([1,61], 'camera1') it would not have an error, but rather assign Nothing to scn. ''' # <- this ends the docstring # now, we get our scene if scn: # if we have a name, (instead of None), do this: renderScene = Blender.Scene.Get(scn) # assign the scene by that name to 'renderScene' else: # otherwise, do this: renderScene = Blender.Scene.GetCurrent() # assume current scene # now we need our rendering context, i.e. the frames etc... context = renderScene.getRenderingContext() # now we assign our camera and frames cam = Blender.Object.Get(camname) # get the camera renderScene.setCurrentCamera(cam) # assign it as the current camera context.sFrame = frames # set the first variable in the list 'frames' to the startframe context.eFrame = frames # do the same for the endframe and second variable # now we are ready to render... context.renderAnim()
that should do it, you can also add stuff like paths to render to, check here:
for more stuff you can add
now to call it, here’s how:
heres three frame batches, you WILL NEED TO EDIT THIS TO YOUR NEEDS!!!
anim([1,50],‘topcam’,‘scene3’) # render 1-50 of scene3 from camera ‘topcam’
anim([34,65],‘sidecam’) # render 34-65 from the same scene with camera ‘sidecam’
anim([6,547],‘camera.003’,‘lost_attic_scene’) # render 6-547, you get the idea.