Created
June 23, 2013 09:14
-
-
Save anonymous/5844378 to your computer and use it in GitHub Desktop.
test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bl_info = { | |
'name': 'Move origin to selected', | |
'author': 'Dealga McArdle (zeffii)', | |
'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): | |
"""Tooltip""" | |
bl_idname = "object.origin_to_selected" | |
bl_label = "Origin Move To Selected" | |
@classmethod | |
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.view3d.snap_cursor_to_selected() | |
bpy.ops.object.mode_set(mode = 'OBJECT') | |
bpy.ops.object.origin_set(type='ORIGIN_CURSOR') | |
bpy.context.scene.cursor_location = saved_location | |
bpy.ops.object.mode_set(mode = 'EDIT') | |
return {'FINISHED'} | |
def register(): | |
bpy.utils.register_class(MoveOrigin) | |
def unregister(): | |
bpy.utils.unregister_class(MoveOrigin) | |
if __name__ == "__main__": | |
register() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment