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?
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
bpy.ops.rigidbody.objects_add(type='ACTIVE')


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