# How do I add a rigidbody to an object with python?

The only method I could find was to use an operator which seems more like a workaround than a solution.

• Could you clarify? Add a rigid body object to the mesh, or add rigid body properties to the mesh? More information is better, and you are more likely to get an answer. – VRM Jan 2 '15 at 20:48
• I meant a rigid body object to an object in the scene, though adding properties to the rigid body would be helpful too – hell2o Jan 2 '15 at 22:01
• The answer for 2.8 blender.stackexchange.com/questions/136687/… – Dazotaro Apr 9 '19 at 22:35

This will add rigid body to the object (add the object to the rigid body group of the scene)

C.scene.rigidbody_world.group.objects.link(C.object)


as zeffii pointed this assumes that a rigid_body_world has been created, which is done with bpy.ops.rigidbody.world_add()

• This seems to assume that the rigid body world has been enabled. Which might not be the case until the .ops is used at least once. Else rigidbody_world is None – zeffii Mar 13 '15 at 17:43
• @zeffii yes, I'll add that in – Chebhou Mar 13 '15 at 17:45

Select an object and make sure no other object is selected (deselect them if that is the case), then run the following script to add a rigid body to the object of your choice.

I found this out by hovering my mouse over the 'Rigid Body' button... the tool tip is 'bpy.ops.rigidbody.objects_add()'

import bpy