Changeset 175

Show
Ignore:
Timestamp:
10/16/06 16:04:49 (2 years ago)
Author:
conrad
Message:

add auto-rendering

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • blender-scripts/logogen.py

    r173 r175  
    44 
    55import math 
     6import sys 
    67import Blender as B 
    78 
     
    6566# Render 
    6667 
    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. 
     71def _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 
     91path="/tmp/renderfarm/render" 
     92 
     93# Should probably create the paths if not existing. 
     94_mkdir(path) 
     95 
     96scene= B.Scene.GetCurrent() 
     97context = scene.getRenderingContext() 
     98context.setRenderPath(path) 
     99context.setImageType(B.Scene.Render.PNG) 
     100context.enableExtensions(1) 
     101 
     102context.renderAnim()