Changing object origin to arbitrary point without origin_set()? Is there a way to change the origin of an object to an arbitrary point (via scripting) without using the operator origin_set()?  I.e., isn't there a method or property on the object to do this?

I know I can do it like this:

bpy.context.scene.cursor_location = pt
bpy.ops.object.origin_set(type='ORIGIN_CURSOR')


but this can get tedious, e.g., if I have other objects selected.
you could do something like this in Edit mode.

obj.data.transform(mathutils.Matrix.Translation(-new_origin))
obj.location += new_origin


I use it in this addon which sets the origin to the selected vertex, or median.



or as CoDEmanX points out

obj.data.transform(mathutils.Matrix.Translation(-new_origin))
obj.matrix_world.translation += new_origin