| 67 | | #c = scene.getRenderingContext() |
|---|
| 68 | | #c.renderPath = "/tmp/render" |
|---|
| 69 | | #c.render() |
|---|
| | 68 | # from http://en.wikibooks.org/wiki/Blender_3D:_Blending_Into_Python/Cookbook#Render_to_a_dir |
|---|
| | 69 | |
|---|
| | 70 | # recursive dir creation. |
|---|
| | 71 | def _mkdir(newdir): |
|---|
| | 72 | import os, sys |
|---|
| | 73 | """works the way a good mkdir should :) |
|---|
| | 74 | - already exists, silently complete |
|---|
| | 75 | - regular file in the way, raise an exception |
|---|
| | 76 | - parent directory(ies) does not exist, make them as well |
|---|
| | 77 | """ |
|---|
| | 78 | if os.path.isdir(newdir): |
|---|
| | 79 | pass |
|---|
| | 80 | elif os.path.exists(newdir): |
|---|
| | 81 | raise OSError("a file with the same name as the desired " \ |
|---|
| | 82 | "dir, '%s', already exists." % newdir) |
|---|
| | 83 | else: |
|---|
| | 84 | head, tail = os.path.split(newdir) |
|---|
| | 85 | if head and not os.path.isdir(head): |
|---|
| | 86 | _mkdir(head) |
|---|
| | 87 | #print "_mkdir %s" % repr(newdir) |
|---|
| | 88 | if tail: |
|---|
| | 89 | os.mkdir(newdir) |
|---|
| | 90 | |
|---|
| | 91 | path="/tmp/renderfarm/render" |
|---|
| | 92 | |
|---|
| | 93 | # Should probably create the paths if not existing. |
|---|
| | 94 | _mkdir(path) |
|---|
| | 95 | |
|---|
| | 96 | scene= B.Scene.GetCurrent() |
|---|
| | 97 | context = scene.getRenderingContext() |
|---|
| | 98 | context.setRenderPath(path) |
|---|
| | 99 | context.setImageType(B.Scene.Render.PNG) |
|---|
| | 100 | context.enableExtensions(1) |
|---|
| | 101 | |
|---|
| | 102 | context.renderAnim() |
|---|