Skip to content

Instantly share code, notes, and snippets.

Forked from anonymous/
Last active February 12, 2024 10:47
Show Gist options
  • Save zeffii/5844379 to your computer and use it in GitHub Desktop.
Save zeffii/5844379 to your computer and use it in GitHub Desktop.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
bl_info = {
'name': 'Move origin to selected',
'author': '',
'version': (0, 0, 1),
'blender': (2, 6, 7),
'location': '3d view > space bar > Origin Move to Selected',
'description': 'in edit mode, sets object origin to the median of selected verts/edges/faces',
'wiki_url': '',
'tracker_url': '',
'category': '3D View'}
import bpy
class MoveOrigin(bpy.types.Operator):
bl_idname = "object.origin_to_selected"
bl_label = "Origin Move To Selected"
bl_options = {'REGISTER', 'UNDO'}
def poll(cls, context):
obj = context.active_object
return obj is not None and obj.mode == 'EDIT'
def execute(self, context):
saved_location = bpy.context.scene.cursor_location.copy()
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.context.scene.cursor_location = saved_location
bpy.ops.object.mode_set(mode = 'EDIT')
return {'FINISHED'}
def register():
def unregister():
if __name__ == "__main__":
Copy link

Very helpful addon, thanks!

Copy link

avex48 commented Jan 25, 2018

Hi @zeffii, had tried to contact you via "blenderstackexchange" and in this page "" I had written this message:
Hello zeffii, forgive me if I steal some attention from you. I'm a chess enthusiast, I modeled a chessboard ( and (not knowing Python) I embarked on writing a program that reads a game from a PGN file and, controlled by a Tkinter interface via the Forward, Back buttons etc., should make moves on the chessboard. The program is only sketched out, and I found out only now that the moves are executed, but the 3D view updates only when the script ends. I have looked for solutions on the web and none seem to work.

I tried to implement the brilliant solution you proposed in the script of the page "…; but given my poor python knowledge I could not get any results!

If I sent you the Blender file and the script, would you have the chance to give it a look?
Thank you and excuse me for the length of the message. Translated with
.... and thank you very much for this very useful addon.

Avelino De Sabbata

Copy link

Thx alot, thought i will script this myself but then i found your script :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment