I'm trying to write a script to add rigid body objects to all objects in the scene. I found this question helpful: How do I add a rigidbody to an object with python?

But when I try the solutions I get a 'context is incorrect' error. I have tried changing the context: bpy.context.area.type = "VIEW_3D" but I still get the error. What is the correct context?

  • $\begingroup$ Which operator is giving the error? You need to have a context.object or context.selected_objects to use rigidbody.object(s)_add $\endgroup$
    – batFINGER
    Commented Oct 21, 2015 at 17:40
  • $\begingroup$ bpy.ops.rigidbody.world_add.poll() failed. I am unclear as to what I need to do with the context in order to add the rigid body world and the rigid body objects, and the documentation I've read has been confusing. $\endgroup$
    – elu
    Commented Oct 22, 2015 at 23:11
  • $\begingroup$ You might find the script in my question helpful: blender.stackexchange.com/questions/49290/… I am stuck in a different place there, but adding a rigid_body works. $\endgroup$ Commented Mar 22, 2016 at 20:42

1 Answer 1


This worked for me:

candidate_list = [item.name for item in bpy.data.objects if item.type == "MESH"]
for object_name in candidate_list:
    bpy.data.objects[object_name].select = True

In the loop it selects all the objects that you want to add rigid_body to. Then add them in one go.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .