Featured post

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/ As of 10/11 november 2015 we can now link to the current api docs and not be worr...

May 14, 2011

Blender 2.5 Python Moving Object Origin

the tooltip for changing the origin (with object selected in object mode) = shift+ctrl+alt+c. says: bpy.ops.object.origin_set(...)

a pretty painless procedure, but maybe a little obfuscated.
- copy the coordinates of your current 3d cursor
- set the 3d cursor to your desired world coordinates
- set the object origin to the 3d cursor
- update
- set the 3d cursor back to it's initial position
- update (if needed )

that in python looks like
import bpy
# store the location of current 3d cursor
saved_location = bpy.context.scene.cursor_location.copy()  # returns a copy of the vector

# give 3dcursor new coordinates
bpy.context.scene.cursor_location = (1.0,0.0,0.0)

# set the origin on the current object to the 3dcursor location

# set 3dcursor location back to the stored location
bpy.context.scene.cursor_location = saved_location


  1. the script doesn't move the cursor back for me. I think it's because python checks to see the value of the variable at the time it is called. By the time you set the cursor back to the "saved_location", python looks at the new 3dcursor coordinates instead of the initial ones at the start of the script. I really wish I knew how to remedy that.

  2. Replies
    1. Omg thanks so much! That helps me out a ton now.


Please use Blender.StackExchange.com for python scripting questions unrelated to this post.