Copy keyframes from one to many objecs OR encode keyframes in script

Hello everyone,

Using a script that I wrote, I created a set of 3000 planks of wood, mimicking the real-life Kapla, that I animate with the Rigid Body Tools. I would like them to be animated only after a specific frame, say 500, because I want to keep the structure intact at the beginning, and I do not want Blender to do a lot of useless computations before that frame.

I managed to make this happen for one object, by checking the “Rigid Body > Dynamic” checkbox; but I have a lot of elements, and the “Copy From Active” tool does not copy the keyframes.

Is it possible to actually copy the keyframes from one rigid body to another one? Is it possible to create these keyframes in the script that creates the object?

For information, I used this code to create a box:
bpy.ops.mesh.primitive_cube_add(location=(x, y, z))

Thanks for any help on my way to the solution!

This is not a complete answer, it is a partial answer . . . the following link will take you to a script that creates keyframes in the script that creates an object . . . . be forewarned, you may need to study it for a while to figure it out. Since I have done so, I will give you some hints . . . it creates the keyframes in frame positions n-5, then when it does the calculations the keyframes are spread out wider, that is why you will see a for n to 5 loop first. I hacked it down some to figure it all out. I just inserted the lines in the console one by one to see what it was doing too. This should help you out, once you get past figuring out how it works.

http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Cookbook/Code_snippets/Actions_and_drivers

#pick the keys of the object 'background'
# the object must have keys on the three canals x,y,z for the same frame

XKeyIsthe=0
YKeyIsthe=1
ZKeyIsthe=2

import bpy,mathutils
from mathutils import Vector
scene=bpy.data.scenes['Scene']

o=scene.objects['background']
NbPt=len(o.animation_data.action.fcurves[XKeyIsthe].keyframe_points)
Points=[]

for p in range(NbPt):
    fr=o.animation_data.action.fcurves[XKeyIsthe].keyframe_points[p].co[0]
    point=[fr]
    point.append(o.animation_data.action.fcurves[XKeyIsthe].keyframe_points[p].co[1])
    if fr != o.animation_data.action.fcurves[YKeyIsthe].keyframe_points[p].co[0]:
        print('error',p,1)
    point.append(o.animation_data.action.fcurves[YKeyIsthe].keyframe_points[p].co[1])
    if fr != o.animation_data.action.fcurves[ZKeyIsthe].keyframe_points[p].co[0]:
        print('error',p,2)

    point.append(o.animation_data.action.fcurves[ZKeyIsthe].keyframe_points[p].co[1])
    Points.append(point)


for i in range(10):
    
    bpy.ops.mesh.primitive_cube_add()
    o=scene.objects[0]
    for point in Points:
        scene.frame_current=point[0]
        o.location=Vector((point[1],point[2],point[3]))
        o.keyframe_insert('location')