# Script to add rigid body to object in scene?

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?

• Which operator is giving the error? You need to have a context.object or context.selected_objects to use rigidbody.object(s)_add – batFINGER Oct 21 '15 at 17:40
• 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. – elu Oct 22 '15 at 23:11
• 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. – Amelse Etomer Mar 22 '16 at 20:42

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

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