I want to rerun the fluid bake. I'm using the code at https://blender.stackexchange.com/a/311453/158745 to bake the fluid, which seems to work.
I try a variation on this code, to free the fluid:
import bpy
for scene in bpy.data.scenes:
# print('scene', scene)
for object in scene.objects:
# print('object', object)
for modifier in object.modifiers:
# print('modifier', modifier, 'modifier_type', modifier.type)
if modifier.type == 'FLUID':
# print('modifier.fluid_type', modifier.fluid_type)
if modifier.fluid_type == 'DOMAIN':
print('freeing...')
object.select_set(True)
bpy.context.view_layer.objects.active = object
bpy.ops.fluid.free_all()
bpy.ops.wm.save_mainfile()
This technically succeeds in freeing the fluid bake. However, re-running the commandline fluid bake, does not error, but the fluid renders as unbaked, ie we just see the entire domain, rather than the fluid.
How to free a fluid bake in a way taht rebaking works ok?
(Alterantively, how to run a fluid bake, from commandline, overwrtiing any existing bake?)
(PS if I try to free the fluid and rebake, in the same loop, then the script crashes, which is why I split it into two scripts)
(removing the cache_fluid folder, then rerunning fluid bake also leads to same result: fluid is no longer baked, cannot re-bake)
(Note that the function above seems to work ok on Mac, just not in my cloud Ubuntu instance)