# Bake Fluid Simulation via CLI or Python?

I would like to run a fluid simulation on a headless Ubuntu machine I have lying around. I did manage to find a bug report on the issue but to no avail. Has anyone else had any success? Or perhaps a better solution to my problem?

• Seems not to work for 2.69 and 2.70a. Only an issue on Windows 8.1 (64bit i5 mobile) No Problem on Linux (Ubuntu 12 and 14) Posted a comment here: developer.blender.org/T28725 regards, F99 (edit:) ok, the essence of the post is, the operator bpy.ops.fluid.bake() is simply not working. It returns "finished", but the bake is NOT started at all. – user3423 May 9 '14 at 11:08
• Works fine for me.. Is it possible you could upload a file where it doesn't work? – gandalf3 Apr 16 '15 at 4:07
• How do I upload a file here? – user13796 Apr 16 '15 at 4:11
• You can't upload .blends directly to SE at this time, but pasteall is a good blender-specific option for temporary usage. For more permanent storage, there's blend-exchange – gandalf3 Apr 16 '15 at 4:14

It's a bit more complicated than it could be because fluid simulating baking is only exposed as an operator. That means it expects an active object in the context, which is usually provided by the user interface that is not available in background mode.

It is possible to pass this object to the operator manually however. The following is an example script that bakes all fluid domain objects in all scenes:

import bpy

for scene in bpy.data.scenes:
for object in scene.objects:
for modifier in object.modifiers:
if modifier.type == 'FLUID_SIMULATION':
if modifier.settings.type == 'DOMAIN':
bpy.ops.fluid.bake({'scene': scene, 'active_object': object})
break


This works when executed from the command line with a command like this:

blender --background file.blend --python script.py

• Just out of curiosity, are you Brecht van Lommel, the Cycle Developer? – Quazi Irfan Jun 10 '13 at 5:17
• Yes, that's me. – brecht Jun 10 '13 at 18:12
• This answer just made my day - only the co-producer of Blender could figure out how to bake fluids. – Cheshire Cat Aug 22 '15 at 17:54
• Does this mean we can in fact bake multiple domains with one command? The UI complains when there are multiple domain objects – Nino van Hooff Nov 5 '17 at 0:17