System Information
Operating system: Windows 10 Home 1909 (64-bit)
Graphics card: NVidia GeForce GTX 1050 Ti
Blender Version
Broken: 2.90.0
Worked: Unknown
Short description of error
When calling bpy.ops.rigidbody.object_add() from inside of a Panel it gives the following error:
Error: Traceback (most recent call last):
File "\Text", line 9, in execute
File "C:\Program Files\Blender Foundation\Blender 2.90\2.90\scripts\modules\bpy\ops.py", line 201, in __call__
ret = op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.rigidbody.object_add.poll() failed, context is incorrectUnfortunately this completely breaks my custom rigging addon.
Exact steps for others to reproduce the error
Starting with a new General Blend file:
- Run the following code as a Text (it will automatically create an armature and panel):
import bpy
from bpy.utils import register_class
class Create(bpy.types.Operator):
bl_label = "Test"
bl_idname = "test.create"
def execute(self, context):
bpy.ops.mesh.primitive_cube_add(size=1.0, calc_uvs=False, enter_editmode=False, location=(6, 0, 0))
bpy.ops.rigidbody.object_add()
return {'FINISHED'}
class DATA_PT_test(bpy.types.Panel):
bl_label = "Test"
bl_region_type = 'WINDOW'
bl_space_type = 'PROPERTIES'
bl_context = 'object'
def draw(self, context):
self.layout.operator("test.create")
register_class(Create)
register_class(DATA_PT_test)
bpy.ops.object.armature_add(enter_editmode=False, location=(3, 0, 0))- Select the default cube.
- In the Object Properties tab, find the Test panel and then click the Test button. It will correctly create a new cube and add rigid body to it.
- Select the armature, then click the Test button. It correctly creates the new cube, however when adding the rigid body it gives the context is incorrect error.