0
$\begingroup$

Before Mantaflow (2.82+), we were able to bake smoke sims with custom python code like follows:

o = bpy.context.selected_objects[0]
c = {}
c['point_cache'] = o.modifiers['Smoke'].domain_settings.point_cache
bpy.ops.ptcache.bake(c, bake=True)

o in this case is the selected object (Smoke Domain), while c is a custom context supplied to the op. Now with Mantaflow, I've tried the following, which causes Blender to crash:

o = bpy.context.selected_objects[0]
c = {}
c['point_cache'] = o.modifiers['Fluid'].domain_settings.point_cache
bpy.ops.fluid.bake_data(c)

Resulting error isn't much help:

Error   : EXCEPTION_ACCESS_VIOLATION
Address : 0x00007FF71D40835C
Module  : C:\Program Files\Blender Foundation\Blender 2.82\blender.exe

What is the correct way of calling fluid.bake_data() in custom python code?

Thanks for your help!

$\endgroup$
1
  • $\begingroup$ I'm curious if you ever worked this out? I'm trying to bake fluids in python and am running into a similar issue when running bpy.ops.fluid.bake_all() $\endgroup$
    – d2kagw
    Commented Jun 6, 2020 at 21:58

1 Answer 1

1
$\begingroup$

This works to an extent for me on an AWS GPU instance:

for scene in bpy.data.scenes:
for object in scene.objects:
    for modifier in object.modifiers:
        print(object.name, " - modifier type: ", modifier.type)
        if modifier.type == 'FLUID':
            print(object.name, " - fuid_type: ", modifier.fluid_type)
            if modifier.fluid_type == 'DOMAIN':
                print("Bake All: ", object.name)
                bpy.ops.fluid.bake_all({'scene': scene, 'active_object': object})
                break

The problem I have is that I have three objects

$\endgroup$

You must log in to answer this question.

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