4
$\begingroup$

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

$\endgroup$
3
  • $\begingroup$ 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. $\endgroup$ – VRM Jan 2 '15 at 20:48
  • $\begingroup$ I meant a rigid body object to an object in the scene, though adding properties to the rigid body would be helpful too $\endgroup$ – hell2o Jan 2 '15 at 22:01
  • 1
    $\begingroup$ The answer for 2.8 blender.stackexchange.com/questions/136687/… $\endgroup$ – Dazotaro Apr 9 '19 at 22:35
6
$\begingroup$

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()

$\endgroup$
2
  • $\begingroup$ 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 $\endgroup$ – zeffii Mar 13 '15 at 17:43
  • $\begingroup$ @zeffii yes, I'll add that in $\endgroup$ – Chebhou Mar 13 '15 at 17:45
0
$\begingroup$

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
bpy.ops.rigidbody.objects_add()
bpy.context.scene.objects.active.rigid_body.type=True # Set to False for Passive objects
$\endgroup$
2
  • $\begingroup$ In the question I did specify that I wasn't looking for an operator as blender.org/api/blender_python_api_2_73_release/… seems to imply that operators shouldn't be used in scripting with "Blender’s operators are tools for users to access" or at least that was what I thought it implied when reading previously $\endgroup$ – hell2o Jan 12 '15 at 9:26
  • $\begingroup$ So you did. I've done some more searching, but came up with no solution. It appears that via python, the 'rigid_body' component of an 'object' is readonly. (blender.org/api/blender_python_api_2_73_release/…) $\endgroup$ – JohnD Jan 13 '15 at 22:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.