1
$\begingroup$

I am using Blender 2.77 and want to render many smoke simulations in cycles from a script. The idea is to take one template smoke simulation, change the parameters as specified in a csv table, render with the changed parameters and then move on to the line in the csv table. Whenever I run my script, the rendered output of the smoke simulation is the same although the parameters are changed in the blend file. I suspect that I need to rerun the smoke simulation each time I want to render, but I am not sure how to do that.

# for each line in csv file do this
for k in range(len(outputName)):

# skip first line
if k == 0:
    print (" skip header")
else:   
    # change smoke settings according to csv file

    # get the attributes from the Camera, Flow and Domain object
    myFlow   = bpy.data.objects["Circle"].modifiers["Smoke"].flow_settings
    myDomain = bpy.data.objects["Smoke Domain"].modifiers["Smoke"].domain_settings


    # get the domain and flow attributes
    smokeVorticity  = myDomain.vorticity  # amount of turbulence
    smokeAlpha      = myDomain.alpha
    smokeDensity    = myFlow.density
    smokeTempDiff   = myFlow.temperature                

    # set domain and flow attributes
    smokeVorticity     = vorticity[k]
    smokeAlpha          = alpha[k]
    smokeDensity        = density[k]


    # set windforce
    bpy.data.objects["Field"].field.strength = float(force[k])

    # set render output settings
    bpy.data.scenes["Smoke"].cycles.seed = int(seed[k])

    # set number of samples to render each pixel (the more the longer it takes)
    bpy.data.scenes["Smoke"].cycles.samples = 3  #crank this up to at least 300

    # set end frame
    bpy.data.scenes["Smoke"].frame_end = 50  # change this to 100 later

    # set render path: 
    fileName = bpy.path.basename(bpy.context.blend_data.filepath)
    fileName = os.path.splitext(fileName)[0]
    bpy.data.scenes["Smoke"].render.filepath = os.path.join("//renderings", "smoke", outputName[k], outputName[k] + "_" )


    # render the scene
    bpy.ops.render.render(animation =True)
    print(outputName[k] + " rendered, moving on to next file")
$\endgroup$
1
  • $\begingroup$ I realized that I did not free the cache and baked for each render. So I added that piece of code:<br/> <br/> # free bake cache<br/> bpy.ops.ptcache.free_bake_all()<br/> # bake the smoke simulation<br/> bpy.ops.ptcache.bake_all(bake = True)<br/> <br/> However, that still does not solve the problem, and when I run my script, I am still getting empty frames. <br/> Here is a link to the blend file: <br/>[link]dropbox.com/s/gtkmx8d98i2gcu4/… [link] $\endgroup$
    – makinate
    Nov 18, 2016 at 19:43

1 Answer 1

1
$\begingroup$

I figured it out; I needed to free the bake cache before baking:

    # free bake cache
    bpy.ops.ptcache.free_bake_all()

    # bake the smoke simulation
    bpy.ops.ptcache.bake_all(bake = True)
$\endgroup$
1
  • $\begingroup$ this did not solve the issue. Anyone? $\endgroup$
    – makinate
    Nov 18, 2016 at 19:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .