Add a cube, add a bezier,
Select cube, run this:
import bpy
import bmesh
bpy.ops.object.constraint_add(type=‘CHILD_OF’)
bpy.context.object.constraints[“Child Of”].target = bpy.data.objects[“BezierCurve”]
bpy.ops.constraint.childof_clear_inverse(constraint=“Child Of”, owner=‘OBJECT’)
bpy.ops.constraint.childof_set_inverse(constraint=“Child Of”, owner=‘OBJECT’)
And Set Inverse is like not run. (same with ‘clear_inverse’ line removed.)
Thanks