Physics not working as expected I want to drop an element on a plane. Here you can see what happens:



This is my blender file: https://easyupload.io/bh6k7d

I load the object in my python script and set it as a rigid body:

scene = bpy.context.scene
cam = bpy.data.objects['Camera']
obj = bpy.data.objects['Cube']
plane = bpy.data.objects['Plane']

bpy.ops.import_mesh.stl(filepath=path)
obj.data = bpy.context.object.data
bpy.data.objects.remove(bpy.context.object)
scene.rigidbody_world.group.objects.link(obj)


The plane is set to rigid body passive.

I want the object to really fall onto the plane. Anyone knows what I am doing wrong?
You need to set the origin of the object to its center of mass else the simulation will become wonky. 
Select your object.

obj = bpy.data.objects['Cube']

obj.select_set(True)


While the object is selected in object mode, right click > Set Origin > To center of mass.

bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_VOLUME', center='MEDIAN')


Also, Apply scale with CTRL + A so that it is uniform at 1,1,1.

bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)


Check the difference here between one cube with its origin to its center of mass and one which is off-center. (the two origins of each cube are the yellow dots) :