So at first I was using this while having selected what I wanted to duplicate before :
bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked":False, "mode":'TRANSLATION'}, TRANSFORM_OT_translate={"value":(0, 0, PH+PH), "constraint_axis":(False, False, True), "constraint_orientation":'GLOBAL', "mirror":False, "proportional":'DISABLED', "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False})
But for no reason that I could find the translation would not be made anymore, it would still duplicate but it would then left it at the same position.
Then I read : Duplicating a mesh object
and when using :
new_obj = obj.copy()
new_obj.data = obj.data.copy()
new_obj.animation_data_clear()
scn.objects.link(new_obj)
new_obj.location = new_obj.location + mathutils.Vector((0, 0, PH+PH))
the objects are duplicated and translated as I want but the rigidbody from the original object is lost.
I tried adding a new rigidbody on the new object but this is slow as hell (by adding this)
obj.select = True
bpy.ops.rigidbody.objects_add()
bpy.context.object.rigid_body.collision_shape = 'BOX'
bpy.context.object.rigid_body.use_margin = True
bpy.context.object.rigid_body.collision_margin = 0.01
would anyone know why the duplicate_move stopped working? is there a fastest way to duplicate the rigidbody?
Thanks.