diff options
author | lijenstina <lijenstina@gmail.com> | 2017-07-05 02:22:14 +0300 |
---|---|---|
committer | lijenstina <lijenstina@gmail.com> | 2017-07-05 02:22:14 +0300 |
commit | 99ed610784b804c175d9e189d9a1b3036973ed61 (patch) | |
tree | 9865ee8d7e95d9747a349409139e0849db6d1d60 /space_view3d_pie_menus/pie_snap_menu.py | |
parent | 759595b17b3a4b04f800d2c12e2af80aa63e4c29 (diff) |
3D Viewport Pie Menus: Cleanup, refactor, fix key register
Bumped version to 1.1.5
Pep8 cleanup
Remove the pie_origin_cursor.py since it is not needed anymore
Part of the T51547:
refactor the key unregister code so it matches the official pies
Note: using this code was crashing blender because of Bool Tool
key registration that left out some lingering keys on unregister
reload
Also there were some wrong calls with the unregister within the
pies themselves
Merge some operators where possible (around 7 less in total)
and use passing arguments instead
Add Enable All / Disable all buttons in the preferences
Comment out the code for authors in the init instead of in
individual scripts
Remove unused imports and cameratoto scene prop
Add an icon at end of registrations line
Fix several crashes with operators being called out of context
Diffstat (limited to 'space_view3d_pie_menus/pie_snap_menu.py')
-rw-r--r-- | space_view3d_pie_menus/pie_snap_menu.py | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/space_view3d_pie_menus/pie_snap_menu.py b/space_view3d_pie_menus/pie_snap_menu.py index 9e58e608..b5ca502c 100644 --- a/space_view3d_pie_menus/pie_snap_menu.py +++ b/space_view3d_pie_menus/pie_snap_menu.py @@ -21,8 +21,8 @@ bl_info = { "name": "Hotkey: 'Ctrl Shift Tab'", "description": "Snap Element Menu", - # "author": "pitiwazou, meta-androcto", - # "version": (0, 1, 0), + "author": "pitiwazou, meta-androcto", + "version": (0, 1, 1), "blender": (2, 77, 0), "location": "3d View", "warning": "", @@ -36,9 +36,8 @@ from bpy.types import ( Operator, ) -# Pie Snap - Shift + Tab - +# Pie Snap - Shift + Tab class PieSnaping(Menu): bl_idname = "pie.snapping" bl_label = "Pie Snapping" @@ -72,10 +71,10 @@ class SnapActive(Operator): def execute(self, context): ts = context.tool_settings - if ts.use_snap == True: + if ts.use_snap is True: ts.use_snap = False - elif ts.use_snap == False: + elif ts.use_snap is False: ts.use_snap = True return {'FINISHED'} @@ -88,7 +87,7 @@ class SnapVolume(Operator): def execute(self, context): ts = context.tool_settings - if ts.use_snap == False: + if ts.use_snap is False: ts.use_snap = True ts.snap_element = 'VOLUME' @@ -105,7 +104,7 @@ class SnapFace(Operator): def execute(self, context): ts = context.tool_settings - if ts.use_snap == False: + if ts.use_snap is False: ts.use_snap = True ts.snap_element = 'FACE' @@ -122,7 +121,7 @@ class SnapEdge(Operator): def execute(self, context): ts = context.tool_settings - if ts.use_snap == False: + if ts.use_snap is False: ts.use_snap = True ts.snap_element = 'EDGE' @@ -139,7 +138,7 @@ class SnapVertex(Operator): def execute(self, context): ts = context.tool_settings - if ts.use_snap == False: + if ts.use_snap is False: ts.use_snap = True ts.snap_element = 'VERTEX' @@ -156,7 +155,7 @@ class SnapIncrement(Operator): def execute(self, context): ts = context.tool_settings - if ts.use_snap == False: + if ts.use_snap is False: ts.use_snap = True ts.snap_element = 'INCREMENT' @@ -173,10 +172,10 @@ class SnapAlignRotation(Operator): def execute(self, context): ts = context.tool_settings - if ts.use_snap_align_rotation == True: + if ts.use_snap_align_rotation is True: ts.use_snap_align_rotation = False - elif ts.use_snap_align_rotation == False: + elif ts.use_snap_align_rotation is False: ts.use_snap_align_rotation = True return {'FINISHED'} @@ -220,6 +219,8 @@ class SnapTargetMenu(Menu): # 9 - TOP - RIGHT # 1 - BOTTOM - LEFT # 3 - BOTTOM - RIGHT + + # Pie Snapping - Shift + Tab classes = ( @@ -241,29 +242,27 @@ 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: # Snapping km = wm.keyconfigs.addon.keymaps.new(name='3D View Generic', space_type='VIEW_3D') kmi = km.keymap_items.new('wm.call_menu_pie', 'TAB', 'PRESS', ctrl=True, shift=True) kmi.properties.name = "pie.snapping" -# kmi.active = True addon_keymaps.append((km, kmi)) 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 == "pie.snapping": - km.keymap_items.remove(kmi) + for km, kmi in addon_keymaps: + km.keymap_items.remove(kmi) + addon_keymaps.clear() + if __name__ == "__main__": register() |