diff options
Diffstat (limited to 'space_view3d_pie_menus/pie_cursor.py')
-rw-r--r-- | space_view3d_pie_menus/pie_cursor.py | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/space_view3d_pie_menus/pie_cursor.py b/space_view3d_pie_menus/pie_cursor.py index 195a07bf..568cdd6d 100644 --- a/space_view3d_pie_menus/pie_cursor.py +++ b/space_view3d_pie_menus/pie_cursor.py @@ -21,8 +21,8 @@ bl_info = { "name": "Hotkey: 'Shift S'", "description": "Cursor Menu", - # "author": "pitiwazou, meta-androcto", - # "version": (0, 1, 0), + "author": "pitiwazou, meta-androcto", + "version": (0, 1, 0), "blender": (2, 77, 0), "location": "3D View", "warning": "", @@ -36,23 +36,23 @@ from bpy.types import ( Operator, ) -# SnapCursSelToCenter1 thanks to Isaac Weaver (wisaac) D1963 - +# SnapCursSelToCenter1 thanks to Isaac Weaver (wisaac) D1963 class Snap_CursSelToCenter1(Operator): - """Snap 3D cursor and selected objects to the center \n"""\ - """Works only in Object Mode""" bl_idname = "view3d.snap_cursor_selected_to_center1" bl_label = "Snap Cursor & Selection to Center" + bl_description = ("Snap 3D cursor and selected objects to the center \n" + "Works only in Object Mode") @classmethod def poll(cls, context): - return (context.mode == "OBJECT") + return (context.area.type == "VIEW_3D" and context.mode == "OBJECT") def execute(self, context): context.space_data.cursor_location = (0, 0, 0) for obj in context.selected_objects: obj.location = (0, 0, 0) + return {'FINISHED'} @@ -69,9 +69,10 @@ class Snap_CursorMenu(Menu): icon='CLIPUV_HLT').use_offset = False # 6 - RIGHT pie.operator("view3d.snap_selected_to_cursor", - text="Selection to Cursor (Offset)", icon='CURSOR').use_offset = True + text="Selection to Cursor (Offset)", icon='CURSOR').use_offset = True # 2 - BOTTOM - pie.operator("view3d.snap_cursor_selected_to_center1", text="Selected & Cursor to Center", icon='ALIGN') + pie.operator("view3d.snap_cursor_selected_to_center1", + text="Selected & Cursor to Center", icon='ALIGN') # 8 - TOP pie.operator("view3d.snap_cursor_to_center", text="Cursor to Center", icon='CLIPUV_DEHLT') # 7 - TOP - LEFT @@ -95,8 +96,8 @@ addon_keymaps = [] def register(): for cls in classes: bpy.utils.register_class(cls) - wm = bpy.context.window_manager + wm = bpy.context.window_manager if wm.keyconfigs.addon: # Origin/Pivot km = wm.keyconfigs.addon.keymaps.new(name='3D View Generic', space_type='VIEW_3D') @@ -108,15 +109,13 @@ def register(): def unregister(): for cls in classes: bpy.utils.unregister_class(cls) - wm = bpy.context.window_manager + wm = bpy.context.window_manager kc = wm.keyconfigs.addon if kc: - km = kc.keymaps['3D View Generic'] - for kmi in km.keymap_items: - if kmi.idname == 'wm.call_menu_pie': - if kmi.properties.name == "snap.cursormenu": - km.keymap_items.remove(kmi) + for km, kmi in addon_keymaps: + km.keymap_items.remove(kmi) + addon_keymaps.clear() if __name__ == "__main__": |