I am seeing a context incorrect error if I run this script more than once in the same .blend file. It occurs in Blender 2.82 and 2.90. My understanding of how contexts work is only mediocre but I cannot think of a reason why/how the context would change after running the script multiple times. I also do not know of any context requirements for trying to add a rigid body world. My end goal is to enable rigid body physics for specific objects and I'm pretty sure enabling rigid world is the first step. I've reduced the code to the following:
import bpy
bpy.ops.rigidbody.world_add()
Reproduction steps:
- Open a new general blend file.
- Insert code from above, run once. There will be no error and the rigid body world will be enabled if you look in the "scene tab"
- Run the script again, error will say context is incorrect.
Thanks.