0
$\begingroup$

I am trying to make rigid body objects start to fall at specific frames. I've tried using the following code to advance to the frame I would like, then import and set the rigid body properties. When I play the animation, all the objects are there at the first frame and fall right away? Am I doing something wrong?

bpy.context.scene.frame_set(frame=100)
bpy.ops.import_mesh.stl(filepath="C://Users/deden/Desktop/x0y0z0h1.stl")
bpy.ops.rigidbody.object_add(type="ACTIVE")
bpy.context.scene.frame_set(frame=200)
bpy.ops.import_mesh.stl(filepath="C://Users/deden/Desktop/x0y0z0h1.stl")
bpy.ops.rigidbody.object_add(type="ACTIVE")

I've managed to get the effect working using the following code, but I just feel that baking isn't the right way to do this? Also sometimes I get weird errors like most of the objects fall but the last few don't? Takes a while to bake as well..

bpy.ops.import_mesh.stl(filepath="C://Users/deden/Desktop/x0y0z0h1.stl")
bpy.ops.rigidbody.object_add(type="ACTIVE")    
bpy.ops.rigidbody.bake_to_keyframes(frame_start=frame, frame_end=endframe, step=1)

I'm a total blender noob..would definitely appreciate some advice. I've seen some similar posts but could not understand/get the desired effect from the answers.

Thanks!!

$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.