Baking particle systems from Python

Good morning,

I’m fairly new at scripting Python for Blender 2.6, so I may be missing something obvious. Any advice is greatly appreciated!

What I want to do, is bake/free a particle system that is attached to a simple mesh, from a python script.

There is a function for this: bpy.ops.ptcache.bake
But I keep getting the error that I have an incorrect context.

Possibly related: I was looking through the API documentation, and apparently there is a particle_system field of bpy.context for the Button context. I am not sure what that means exactly, but there is definitely no such field in my current context: dir(bpy.context)

Anyone know what I’m doing wrong?

  • Ben