Skip to main content
Share Your Experience: Take the 2024 Developer Survey
3 of 7
replaced with

Baking smoke is very similar to baking fluid, so I will quote brecht's answer:

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.

However, it is possible to override context manually, see the api docs.

So for a smoke simulation:

import bpy

for scene in
    for object in scene.objects:
        for modifier in object.modifiers:
            if modifier.type == 'SMOKE':
                if modifier.smoke_type == 'DOMAIN':
                    override = {'scene': scene, 'active_object': object, 'point_cache': modifier.domain_settings.point_cache}
                    bpy.ops.ptcache.bake(override, bake=True)

This will bake the selected cache for all domain objects in the file.

You can then run this python script in blender with

blender --background /path/to/file.blend --python /path/to/

Or the short way:

blender -b /path/to/file.blend -P /path/to/
  • 157.4k
  • 59
  • 606
  • 1.1k