[Durian-svn] [5138] first pass on batch smoke bake script

campbell institute at blender.org
Tue Jun 15 18:48:22 CEST 2010


Revision: 5138
          https://blenderinstitute.dyndns.org/durian-svn/?do=log&project=durian&path=/&rev=5138
Author:   campbell
Date:     2010-06-15 18:48:22 +0200 (Tue, 15 Jun 2010)
Log Message:
-----------
first pass on batch smoke bake script

Added Paths:
-----------
    pro/scripts/utilities/batch_bake_smoke.py

Added: pro/scripts/utilities/batch_bake_smoke.py
===================================================================
--- pro/scripts/utilities/batch_bake_smoke.py	                        (rev 0)
+++ pro/scripts/utilities/batch_bake_smoke.py	2010-06-15 16:48:22 UTC (rev 5138)
@@ -0,0 +1,82 @@
+import random
+import os
+# export SMOKE_SEED=1
+# /media/data/blender_$USER/blender/blender --background /home/ideasman42/fire_to_test.blend  --python /d/pro/scripts/utilities/batch_bake_smoke.py
+
+RENDER_DIR = "/tmp/"
+
+def preset_apply(settings, seed, log):
+    random.seed(seed)
+
+    for data_string, val_min, val_max in settings:
+        val = eval(data_string)
+        if type(val) == float:
+            exec_str = "%s = %f" % (data_string, random.uniform(val_min, val))
+        else:
+            exec_str = "%s = %d" % (data_string, int(round(random.uniform(val_min, val))))
+
+        exec(exec_str)
+        log.append(exec_str)
+
+
+def setup_smoke():
+    
+    seed = os.environ['SMOKE_SEED']
+    seed = int(seed)
+
+    logs = []
+
+    # setup hard coded settings
+    # example!
+    settings = [
+        ('bpy.data.objects["Mesh"].modifiers["ParticleSystem 1"].particle_system.settings.random_lifetime', 0.2, 1.0),
+        ('bpy.data.objects["Mesh"].modifiers["ParticleSystem 1"].particle_system.settings.amount', 0.2, 1.0),
+        ('bpy.data.objects["Mesh"].modifiers["ParticleSystem 1"].particle_system.settings.random_size', 0.1, 0.8),
+        ('bpy.data.objects["Mesh"].modifiers["ParticleSystem 1"].particle_system.settings.random_size', 0.2, 2.0),
+        ('bpy.data.objects["Mesh"].modifiers["ParticleSystem 1"].particle_system.settings.time_tweak', 0.1, 0.8),
+        ('bpy.data.objects["Cube"].modifiers["Smoke"].domain_settings.amplify', 3, 8),
+        ('bpy.data.objects["Cube"].modifiers["Smoke"].domain_settings.strength', 1.0, 10.0),
+    ]
+
+    log = []
+    logs.append(log)
+    preset_apply(settings, seed, log)
+
+    base_context = {
+        "scene": bpy.context.scene,
+        "main": bpy.context.main,
+        "active_object": None,
+        "object": None
+    }
+    
+    bpy.ops.ptcache.free_bake_all()
+    
+    for obj in bpy.data.objects:
+        for md in obj.modifiers:
+            if md.type == 'SMOKE' and md.smoke_type == 'DOMAIN':
+                context = base_context.copy()
+                context["point_cache"] = md.domain_settings.point_cache_high
+
+                bpy.ops.ptcache.free_bake(context)
+                bpy.ops.ptcache.bake(context, bake=True)
+
+    # now render!
+    bpy.context.scene.render.resolution_percentage = 10
+    bpy.context.scene.render.resolution_x = 2048
+    bpy.context.scene.render.resolution_y = 872
+    bpy.context.scene.render.file_format = 'AVI_JPEG'
+    bpy.context.scene.render.file_quality = 95
+
+    filepath = bpy.data.filepath.replace(".blend", "_seed-%.2d" % seed)
+    
+    # write log
+    file = open(filepath + ".py", "w")
+    file.writelines([line + "\n" for log in logs for line in log])
+    file.close()
+    
+    bpy.context.scene.render.output_path = os.path.join(RENDER_DIR, os.path.basename(filepath) + ".avi")
+
+    bpy.ops.render.render(animation=True)
+
+if __name__ == "__main__":
+    setup_smoke()



More information about the Durian-svn mailing list