I am trying to bake particle systems from the command line. I saw this: Baking smoke on headless machine and I have been playing around with it, but I can't seem to get it to work for particles. I'm sure there is a way, but I just suck with coding like this.


1 Answer 1


I found this thread which had this code in it. It works perfectly fine!!

import bpy

for scene in bpy.data.scenes:
    for object in scene.objects:
        for modifier in object.modifiers:
            if modifier.type == 'FLUID':
                if modifier.fluid_type == 'DOMAIN':
                    print("Baking fluid")
                    bpy.context.view_layer.objects.active = object
            elif modifier.type == 'CLOTH':
                print("Baking cloth")
                override = {'scene': scene, 'active_object': object, 'point_cache': modifier.point_cache}
                bpy.ops.ptcache.bake(override, bake=True)
            elif modifier.type == 'PARTICLE_SYSTEM':
                print("Baking particles")
                override = {'scene': scene, 'active_object': object, 'point_cache': modifier.particle_system.point_cache}
                bpy.ops.ptcache.bake(override, bake=True)

As you can see, this script bakes fluid, particles, and cloth. To use it, just past the code into a file, save the file as a .py python file, and then in the Blender directory type blender -b "path to .blend file" -P "path to .py file" and Blender will bake it! I hope this helps.


You must log in to answer this question.

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