Sunday, April 12, 2009

How to generate an image from Blender

Blender can be scripted to generate an image using python. Once all of the objects are in place, the rendering and saving of the image can be scripted. The following code snippet shows how to script to generate an image. Animation is handled differently.
import Blender from Blender import * from Blender.Scene import Render scn = Scene.GetCurrent() context = scn.getRenderingContext() # enable seperate window for rendering Render.EnableDispWin() # draw the image context.render() # save the image to disk # to the location specified by RenderPath # by default this will be a jpg file context.saveRenderedImage('test')
If this is done right after starting Blender, the following image should be saved to '\tmp\test.jpg'. It should look like this.

No comments:

Post a Comment