Page MenuHome

Particle system baking not working in Python API
Closed, InvalidPublic

Description

System Information
Operating system: Arch Linux
Graphics card: RTX 2080

Blender Version
Broken: (All, latest check: 2.80)

Description
This code runs OK with no errors except that it does nothing. I have followed the similar patter as when baking smoke or fluid.

for scene in bpy.data.scenes:
    for object in scene.objects:
        for modifier in object.modifiers:
           if modifier.type == 'PARTICLE_SYSTEM':
                print("Baking particles")
                override = {'scene': scene, 'active_object': object, 'point_cache': modifier.particle_system.point_cache}
                bpy.ops.ptcache.free_bake(override)
                bpy.ops.ptcache.bake(override, bake=True)

The cache is empty when I open the file afterwards or try to render. When I set

use_disk_cache = True

the cache folder is created but can't be used by the blend file.

Files
Running as:

blender simpleParticles.blend -b -P bake.py

Details

Type
Bug

Event Timeline

Hitokage created this task.Aug 6 2019, 10:39 AM
Sybren A. Stüvel (sybren) lowered the priority of this task from Needs Triage by Developer to Needs Information from User.Aug 7 2019, 10:09 AM

Please follow our submission template and guidelines and make a complete, valid bug report, with required info, precise description of the issue, precise steps to reproduce it, small and simple .blend and/or other files to do so if needed, etc.

A guideline for making a good bug report can be found here: https://wiki.blender.org/wiki/Process/Bug_Reports

Marking as "Incomplete" until the requested information/data is provided.

Hitokage updated the task description. (Show Details)Aug 7 2019, 10:23 AM

Please follow our submission template and guidelines and make a complete, valid bug report, with required info, precise description of the issue, precise steps to reproduce it, small and simple .blend and/or other files to do so if needed, etc.
A guideline for making a good bug report can be found here: https://wiki.blender.org/wiki/Process/Bug_Reports
Marking as "Incomplete" until the requested information/data is provided.

Sorry, fixed!

Hitokage updated the task description. (Show Details)Aug 7 2019, 11:06 AM
Hitokage updated the task description. (Show Details)Aug 7 2019, 11:13 AM
Hitokage raised the priority of this task from Needs Information from User to Needs Triage by Developer.Aug 19 2019, 2:45 PM
Sybren A. Stüvel (sybren) claimed this task.

The cache is empty when I open the file afterwards

This makes sense, as your script doesn't save the blend file after baking. Adding bpy.ops.wm.save_mainfile() at the end of the script solves both on-disk and in-memory baking.

Marking as 'Invalid' as this isn't a bug in Blender.

Hitokage added a comment.EditedWed, Oct 2, 9:40 AM

I see, thanks but why doesn't this happen when baking for example smoke in the same way?
EDIT: I guess it's because the rest creates external cache directory.