From 1bba102d652cea832ae7da0d1d476739d2e1d8da Mon Sep 17 00:00:00 2001 From: meta-androcto Date: Sun, 11 Aug 2019 11:44:51 +1000 Subject: space_view3d_pie_menus: multiple fixes/updates part 1: T67995 --- space_view3d_pie_menus/__init__.py | 147 ++++++----------- space_view3d_pie_menus/pie_align_menu.py | 56 ++++--- space_view3d_pie_menus/pie_animation_menu.py | 4 +- space_view3d_pie_menus/pie_apply_transform_menu.py | 34 ++-- space_view3d_pie_menus/pie_delete_menu.py | 28 ++-- space_view3d_pie_menus/pie_editor_switch_menu.py | 15 +- space_view3d_pie_menus/pie_manipulator_menu.py | 15 +- space_view3d_pie_menus/pie_modes_menu.py | 12 +- space_view3d_pie_menus/pie_origin.py | 183 ++++++++++++++++++++- space_view3d_pie_menus/pie_proportional_menu.py | 24 ++- space_view3d_pie_menus/pie_save_open_menu.py | 2 +- space_view3d_pie_menus/pie_views_numpad_menu.py | 62 +++---- 12 files changed, 372 insertions(+), 210 deletions(-) (limited to 'space_view3d_pie_menus') diff --git a/space_view3d_pie_menus/__init__.py b/space_view3d_pie_menus/__init__.py index 620e0bd1..32c386e9 100644 --- a/space_view3d_pie_menus/__init__.py +++ b/space_view3d_pie_menus/__init__.py @@ -18,6 +18,7 @@ # +# Contributed to by meta-androcto, pitiwazou, chromoly, italic import bpy from bpy.props import ( @@ -32,10 +33,10 @@ from bpy.types import ( bl_info = { "name": "3D Viewport Pie Menus", - "author": "meta-androcto, pitiwazou, chromoly, italic", - "version": (1, 1, 9), + "author": "meta-androcto", + "version": (1, 2, 8), "blender": (2, 80, 0), - "description": "Individual Pie Menu Activation List", + "description": "Pie Menu Activation", "location": "Addons Preferences", "warning": "", "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/" @@ -51,7 +52,6 @@ sub_modules_names = ( "pie_cursor", "pie_manipulator_menu", "pie_snap_menu", - "pie_orientation_menu", "pie_shading_menu", "pie_proportional_menu", "pie_align_menu", @@ -64,8 +64,7 @@ sub_modules_names = ( ) -sub_modules = [__import__(__package__ + "." + submod, {}, {}, submod) for - submod in sub_modules_names] +sub_modules = [__import__(__package__ + "." + submod, {}, {}, submod) for submod in sub_modules_names] sub_modules.sort(key=lambda mod: (mod.bl_info['category'], mod.bl_info['name'])) @@ -91,20 +90,22 @@ def get_addon_preferences(name=''): cls = _get_pref_class(mod) if cls: prop = PointerProperty(type=cls) - setattr(PieToolsPreferences, name, prop) - bpy.utils.unregister_class(PieToolsPreferences) - bpy.utils.register_class(PieToolsPreferences) + create_property(PIEToolsPreferences, name, prop) + bpy.utils.unregister_class(PIEToolsPreferences) + bpy.utils.register_class(PIEToolsPreferences) return getattr(addon_prefs, name, None) else: return addon_prefs +def create_property(cls, name, prop): + if not hasattr(cls, '__annotations__'): + cls.__annotations__ = dict() + cls.__annotations__[name] = prop + def register_submodule(mod): - if not hasattr(mod, '__addon_enabled__'): - mod.__addon_enabled__ = False - if not mod.__addon_enabled__: - mod.register() - mod.__addon_enabled__ = True + mod.register() + mod.__addon_enabled__ = True def unregister_submodule(mod): @@ -114,91 +115,20 @@ def unregister_submodule(mod): prefs = get_addon_preferences() name = mod.__name__.split('.')[-1] - if hasattr(PieToolsPreferences, name): - delattr(PieToolsPreferences, name) + if hasattr(PIEToolsPreferences, name): + delattr(PIEToolsPreferences, name) if prefs: - bpy.utils.unregister_class(PieToolsPreferences) - bpy.utils.register_class(PieToolsPreferences) + bpy.utils.unregister_class(PIEToolsPreferences) + bpy.utils.register_class(PIEToolsPreferences) if name in prefs: del prefs[name] -def enable_all_modules(self, context): - for mod in sub_modules: - mod_name = mod.__name__.split('.')[-1] - setattr(self, 'use_' + mod_name, False) - if not mod.__addon_enabled__: - setattr(self, 'use_' + mod_name, True) - mod.__addon_enabled__ = True - - return None - - -def disable_all_modules(self, context): - for mod in sub_modules: - mod_name = mod.__name__.split('.')[-1] - - if mod.__addon_enabled__: - setattr(self, 'use_' + mod_name, False) - mod.__addon_enabled__ = False - - return None - - -class PieToolsPreferences(AddonPreferences): +class PIEToolsPreferences(AddonPreferences): bl_idname = __name__ - enable_all: BoolProperty( - name="Enable all", - description="Enable all Pie Modules", - default=False, - update=enable_all_modules - ) - disable_all: BoolProperty( - name="Disable all", - description="Disable all Pie Modules", - default=False, - update=disable_all_modules - ) - - for mod in sub_modules: - mod_name = mod.__name__.split('.')[-1] - - def gen_update(mod, use_prop_name): - def update(self, context): - if getattr(self, use_prop_name): - if not mod.__addon_enabled__: - register_submodule(mod) - else: - if mod.__addon_enabled__: - unregister_submodule(mod) - return update - - use_prop_name = 'use_' + mod_name - __annotations__[use_prop_name] = BoolProperty( - name=mod.bl_info['name'], - description=mod.bl_info.get('description', ''), - update=gen_update(mod, use_prop_name), - ) - - __annotations__['show_expanded_' + mod_name] = BoolProperty() - def draw(self, context): layout = self.layout - split = layout.split(factor=0.5, align=True) - row = split.row() - row.alignment = "LEFT" - sub_box = row.box() - sub_box.prop(self, "enable_all", emboss=False, - icon="HIDE_OFF", icon_only=True) - row.label(text="Enable All") - - row = split.row() - row.alignment = "RIGHT" - row.label(text="Disable All") - sub_box = row.box() - sub_box.prop(self, "disable_all", emboss=False, - icon="HIDE_ON", icon_only=True) for mod in sub_modules: mod_name = mod.__name__.split('.')[-1] @@ -237,7 +167,7 @@ class PieToolsPreferences(AddonPreferences): if info.get('author'): split = col.row().split(factor=0.15) split.label(text='Author:') - split.label(info['author']) + split.label(text=info['author']) """ if info.get('version'): split = col.row().split(factor=0.15) @@ -276,12 +206,41 @@ class PieToolsPreferences(AddonPreferences): del prefs.layout row = layout.row() - row.label(text="End of 3D Viewport Pie Menus Activations", - icon="FILE_PARENT") + row.label(text="End of Pie Menu Activations", icon="FILE_PARENT") + + +for mod in sub_modules: + info = mod.bl_info + mod_name = mod.__name__.split('.')[-1] + + def gen_update(mod): + def update(self, context): + enabled = getattr(self, 'use_' + mod.__name__.split('.')[-1]) + if enabled: + register_submodule(mod) + else: + unregister_submodule(mod) + mod.__addon_enabled__ = enabled + return update + + create_property( + PIEToolsPreferences, + 'use_' + mod_name, + BoolProperty( + name=info['name'], + description=info.get('description', ''), + update=gen_update(mod), + default=True, + )) + + create_property( + PIEToolsPreferences, + 'show_expanded_' + mod_name, + BoolProperty()) classes = ( - PieToolsPreferences, + PIEToolsPreferences, ) diff --git a/space_view3d_pie_menus/pie_align_menu.py b/space_view3d_pie_menus/pie_align_menu.py index 0223be53..e3ad60a9 100644 --- a/space_view3d_pie_menus/pie_align_menu.py +++ b/space_view3d_pie_menus/pie_align_menu.py @@ -47,24 +47,6 @@ class PIE_MT_Align(Menu): layout = self.layout pie = layout.menu_pie() # 4 - LEFT - pie.operator("align.selected2xyz", - text="Align X", icon='TRIA_LEFT').axis = 'X' - # 6 - RIGHT - pie.operator("align.selected2xyz", - text="Align Z", icon='TRIA_DOWN').axis = 'Z' - # 2 - BOTTOM - pie.operator("align.selected2xyz", - text="Align Y", icon='PLUS').axis = 'Y' - # 8 - TOP - pie.operator("align.2xyz", text="Align To Y-0").axis = '1' - # 7 - TOP - LEFT - pie.operator("align.2xyz", text="Align To X-0").axis = '0' - # 9 - TOP - RIGHT - pie.operator("align.2xyz", text="Align To Z-0").axis = '2' - # 1 - BOTTOM - LEFT - pie.separator() - # 3 - BOTTOM - RIGHT - # pie.menu("align.xyz") box = pie.split().box().column() row = box.row(align=True) @@ -72,27 +54,53 @@ class PIE_MT_Align(Menu): align_1 = row.operator("alignxyz.all", text="Neg") align_1.axis = '0' align_1.side = 'NEGATIVE' - align_2 = row.operator("alignxyz.all", text="Pos") - align_2.axis = '0' - align_2.side = 'POSITIVE' row = box.row(align=True) row.label(text="Y") align_3 = row.operator("alignxyz.all", text="Neg") align_3.axis = '1' align_3.side = 'NEGATIVE' - align_4 = row.operator("alignxyz.all", text="Pos") - align_4.axis = '1' - align_4.side = 'POSITIVE' row = box.row(align=True) row.label(text="Z") align_5 = row.operator("alignxyz.all", text="Neg") align_5.axis = '2' align_5.side = 'NEGATIVE' + # 6 - RIGHT + box = pie.split().box().column() + + row = box.row(align=True) + row.label(text="X") + align_2 = row.operator("alignxyz.all", text="Pos") + align_2.axis = '0' + align_2.side = 'POSITIVE' + + row = box.row(align=True) + row.label(text="Y") + align_4 = row.operator("alignxyz.all", text="Pos") + align_4.axis = '1' + align_4.side = 'POSITIVE' + + row = box.row(align=True) + row.label(text="Z") align_6 = row.operator("alignxyz.all", text="Pos") align_6.axis = '2' align_6.side = 'POSITIVE' + # 2 - BOTTOM + pie.operator("align.2xyz", text="Align To Y-0").axis = '1' + # 8 - TOP + pie.operator("align.selected2xyz", + text="Align Y").axis = 'Y' + # 7 - TOP - LEFT + pie.operator("align.selected2xyz", + text="Align X").axis = 'X' + # 9 - TOP - RIGHT + pie.operator("align.selected2xyz", + text="Align Z").axis = 'Z' + # 1 - BOTTOM - LEFT + pie.operator("align.2xyz", text="Align To X-0").axis = '0' + # 3 - BOTTOM - RIGHT + pie.operator("align.2xyz", text="Align To Z-0").axis = '2' # Align to X, Y, Z diff --git a/space_view3d_pie_menus/pie_animation_menu.py b/space_view3d_pie_menus/pie_animation_menu.py index 7bb9baa9..d18b2640 100644 --- a/space_view3d_pie_menus/pie_animation_menu.py +++ b/space_view3d_pie_menus/pie_animation_menu.py @@ -19,7 +19,7 @@ # bl_info = { - "name": "Hotkey: 'Ctrl Shift Spacebar'", + "name": "Hotkey: 'Shift Spacebar'", "description": "Pie menu for Timeline controls", "author": "pitiwazou, meta-androcto", "version": (0, 1, 1), @@ -102,7 +102,7 @@ def register(): if wm.keyconfigs.addon: # Animation km = wm.keyconfigs.addon.keymaps.new(name='Object Non-modal') - kmi = km.keymap_items.new('wm.call_menu_pie', 'SPACE', 'PRESS', ctrl=True, shift=True) + kmi = km.keymap_items.new('wm.call_menu_pie', 'SPACE', 'PRESS', shift=True) kmi.properties.name = "PIE_MT_animation" addon_keymaps.append((km, kmi)) diff --git a/space_view3d_pie_menus/pie_apply_transform_menu.py b/space_view3d_pie_menus/pie_apply_transform_menu.py index 785d5ac5..1b32aa32 100644 --- a/space_view3d_pie_menus/pie_apply_transform_menu.py +++ b/space_view3d_pie_menus/pie_apply_transform_menu.py @@ -47,19 +47,19 @@ class PIE_MT_PieApplyTransforms(Menu): layout = self.layout pie = layout.menu_pie() # 4 - LEFT - pie.operator("apply.transformall", text="Apply All", icon='FREEZE') + pie.operator("object.visual_transform_apply", text="Apply Visual") # 6 - RIGHT - pie.operator("clear.all", text="Clear All", icon='NONE') + pie.operator("apply.transformall", text="Apply All") # 2 - BOTTOM - pie.operator("object.duplicates_make_real", text="Make Instances Real") + pie.operator("apply.transformrotsca", text="Rotation/Scale") # 8 - TOP - pie.operator("apply.transformlocrotscale", text="Rotation", icon='NONE').option = 'ROT' + pie.operator("apply.transformlocrotscale", text="Rotation").option = 'ROT' # 7 - TOP - LEFT - pie.operator("apply.transformlocrotscale", text="Location", icon='NONE').option = 'LOC' + pie.operator("apply.transformlocrotscale", text="Location").option = 'LOC' # 9 - TOP - RIGHT - pie.operator("apply.transformlocrotscale", text="Scale", icon='NONE').option = 'SCALE' + pie.operator("apply.transformlocrotscale", text="Scale").option = 'SCALE' # 1 - BOTTOM - LEFT - pie.operator("object.visual_transform_apply", text="Visual Transforms") + pie.operator("object.duplicates_make_real", text="Make Instances Real") # 3 - BOTTOM - RIGHT pie.menu("PIE_MT_clear_menu", text="Clear Transform Menu") @@ -94,7 +94,7 @@ class PIE_OT_ApplyTransLocRotPie(Operator): class PIE_OT_ApplyTransformAll(Operator): bl_idname = "apply.transformall" bl_label = "Apply All Transforms" - bl_description = "Apply Transform All" + bl_description = "Apply Transform Loc/Rotation/Scale" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): @@ -102,13 +102,26 @@ class PIE_OT_ApplyTransformAll(Operator): return {'FINISHED'} +# Apply Transforms +class PIE_OT_ApplyTransformRotSca(Operator): + bl_idname = "apply.transformrotsca" + bl_label = "Rotation/Scale" + bl_description = "Apply Transform Rotation/Scale" + bl_options = {'REGISTER', 'UNDO'} + + def execute(self, context): + bpy.ops.object.transform_apply(location=False, rotation=True, scale=True) + return {'FINISHED'} + + # Clear Menu -class PIE_OT_ClearMenu(Menu): +class PIE_MT_ClearMenu(Menu): bl_idname = "PIE_MT_clear_menu" bl_label = "Clear Menu" def draw(self, context): layout = self.layout + layout.operator("clear.all", text="Clear All", icon='NONE') layout.operator("object.location_clear", text="Clear Location", icon='NONE') layout.operator("object.rotation_clear", text="Clear Rotation", icon='NONE') layout.operator("object.scale_clear", text="Clear Scale", icon='NONE') @@ -133,8 +146,9 @@ classes = ( PIE_MT_PieApplyTransforms, PIE_OT_ApplyTransLocRotPie, PIE_OT_ApplyTransformAll, - PIE_OT_ClearMenu, + PIE_MT_ClearMenu, PIE_OT_ClearAll, + PIE_OT_ApplyTransformRotSca, ) addon_keymaps = [] diff --git a/space_view3d_pie_menus/pie_delete_menu.py b/space_view3d_pie_menus/pie_delete_menu.py index 3cea1c3d..ee3e2b58 100644 --- a/space_view3d_pie_menus/pie_delete_menu.py +++ b/space_view3d_pie_menus/pie_delete_menu.py @@ -43,27 +43,27 @@ class PIE_MT_PieDelete(Menu): layout = self.layout pie = layout.menu_pie() # 4 - LEFT - pie.operator("mesh.delete", text="Delete Vertices", icon='VERTEXSEL').type = 'VERT' - # 6 - RIGHT - pie.operator("mesh.delete", text="Delete Faces", icon='FACESEL').type = 'FACE' - # 2 - BOTTOM - pie.operator("mesh.delete", text="Delete Edges", icon='EDGESEL').type = 'EDGE' - # 8 - TOP - pie.operator("mesh.dissolve_edges", text="Dissolve Edges", icon='SNAP_EDGE') - # 7 - TOP - LEFT - pie.operator("mesh.dissolve_verts", text="Dissolve Vertices", icon='SNAP_VERTEX') - # 9 - TOP - RIGHT - pie.operator("mesh.dissolve_faces", text="Dissolve Faces", icon='SNAP_FACE') - # 1 - BOTTOM - LEFT box = pie.split().column() box.operator("mesh.dissolve_limited", text="Limited Dissolve", icon='STICKY_UVS_LOC') box.operator("mesh.delete_edgeloop", text="Delete Edge Loops", icon='NONE') box.operator("mesh.edge_collapse", text="Edge Collapse", icon='UV_EDGESEL') - # 3 - BOTTOM - RIGHT + # 6 - RIGHT box = pie.split().column() + box.operator("mesh.remove_doubles", text="Merge By Distance", icon='NONE') box.operator("mesh.delete", text="Only Edge & Faces", icon='NONE').type = 'EDGE_FACE' box.operator("mesh.delete", text="Only Faces", icon='UV_FACESEL').type = 'ONLY_FACE' - box.operator("mesh.remove_doubles", text="Merge By Distance", icon='NONE') + # 2 - BOTTOM + pie.operator("mesh.dissolve_edges", text="Dissolve Edges", icon='SNAP_EDGE') + # 8 - TOP + pie.operator("mesh.delete", text="Delete Edges", icon='EDGESEL').type = 'EDGE' + # 7 - TOP - LEFT + pie.operator("mesh.delete", text="Delete Vertices", icon='VERTEXSEL').type = 'VERT' + # 9 - TOP - RIGHT + pie.operator("mesh.delete", text="Delete Faces", icon='FACESEL').type = 'FACE' + # 1 - BOTTOM - LEFT + pie.operator("mesh.dissolve_verts", text="Dissolve Vertices", icon='SNAP_VERTEX') + # 3 - BOTTOM - RIGHT + pie.operator("mesh.dissolve_faces", text="Dissolve Faces", icon='SNAP_FACE') classes = ( diff --git a/space_view3d_pie_menus/pie_editor_switch_menu.py b/space_view3d_pie_menus/pie_editor_switch_menu.py index 9786fbaa..075083bb 100644 --- a/space_view3d_pie_menus/pie_editor_switch_menu.py +++ b/space_view3d_pie_menus/pie_editor_switch_menu.py @@ -19,7 +19,7 @@ # bl_info = { - "name": "Hotkey: 'Ctrl Alt S ", + "name": "Hotkey: 'Ctrl Alt S' ", "description": "Switch Editor Type Menu", "author": "saidenka, meta-androcto", "version": (0, 1, 0), @@ -111,6 +111,16 @@ class PIE_OT_SetAreaType(Operator): context.area.type = self.types return {'FINISHED'} +class PIE_OT_Timeline(Operator): + bl_idname = "wm.set_timeline" + bl_label = "Change Editor Type" + bl_description = "Change Editor Type" + bl_options = {'REGISTER'} + + def execute(self, context): + bpy.context.area.ui_type = 'TIMELINE' + return {'FINISHED'} + class PIE_MT_AreaTypePieAnim(Menu): bl_idname = "TOPBAR_MT_window_pie_area_type_anim" @@ -121,7 +131,7 @@ class PIE_MT_AreaTypePieAnim(Menu): self.layout.operator(PIE_OT_SetAreaType.bl_idname, text="NLA Editor", icon="NLA").types = "NLA_EDITOR" self.layout.operator(PIE_OT_SetAreaType.bl_idname, text="DopeSheet", icon="ACTION").types = "DOPESHEET_EDITOR" self.layout.operator(PIE_OT_SetAreaType.bl_idname, text="Graph Editor", icon="GRAPH").types = "GRAPH_EDITOR" -# self.layout.operator(PIE_OT_SetAreaType.bl_idname, text="Timeline", icon="TIME").types = "TIMELINE" + self.layout.operator(PIE_OT_Timeline.bl_idname, text="Timeline", icon="TIME") self.layout.operator(PIE_OT_SetAreaType.bl_idname, text="Video Sequence Editor", icon="SEQUENCE").types = "SEQUENCE_EDITOR" self.layout.operator(PIE_OT_SetAreaType.bl_idname, @@ -135,6 +145,7 @@ classes = ( PIE_MT_AreaTypePieOther, PIE_OT_SetAreaType, PIE_MT_AreaTypePieAnim, + PIE_OT_Timeline ) addon_keymaps = [] diff --git a/space_view3d_pie_menus/pie_manipulator_menu.py b/space_view3d_pie_menus/pie_manipulator_menu.py index 8a8b10cb..8d7387e8 100644 --- a/space_view3d_pie_menus/pie_manipulator_menu.py +++ b/space_view3d_pie_menus/pie_manipulator_menu.py @@ -19,8 +19,8 @@ # bl_info = { - "name": "Hotkey: 'Ctrl Space'", - "description": "Extended Manipulator Menu", + "name": "Hotkey: 'Alt Spacebar'", + "description": "Manipulator Menu", "author": "pitiwazou, meta-androcto", "version": (0, 1, 1), "blender": (2, 80, 0), @@ -92,14 +92,15 @@ class PIE_MT_Manipulator(Menu): layout = self.layout pie = layout.menu_pie() # 4 - LEFT - pie.operator("w.manipulators", text="Translate", icon='NONE').type = 'TRANSLATE' - # 6 - RIGHT pie.operator("w.manipulators", text="Rotate", icon='NONE').type = 'ROTATE' - # 2 - BOTTOM + # 6 - RIGHT pie.operator("w.manipulators", text="Scale", icon='NONE').type = 'SCALE' - # 8 - TOP + # 2 - BOTTOM props = pie.operator("wm.context_toggle", text="Show/Hide Toggle", icon='NONE') props.data_path = "space_data.show_gizmo_context" + # 8 - TOP + pie.operator("w.manipulators", text="Translate", icon='NONE').type = 'TRANSLATE' + classes = ( @@ -118,7 +119,7 @@ def register(): if wm.keyconfigs.addon: # Manipulators km = wm.keyconfigs.addon.keymaps.new(name='3D View Generic', space_type='VIEW_3D') - kmi = km.keymap_items.new('wm.call_menu_pie', 'SPACE', 'PRESS', ctrl=True) + kmi = km.keymap_items.new('wm.call_menu_pie', 'SPACE', 'PRESS', alt=True) kmi.properties.name = "PIE_MT_manipulator" addon_keymaps.append((km, kmi)) diff --git a/space_view3d_pie_menus/pie_modes_menu.py b/space_view3d_pie_menus/pie_modes_menu.py index a5197551..0b68c79e 100644 --- a/space_view3d_pie_menus/pie_modes_menu.py +++ b/space_view3d_pie_menus/pie_modes_menu.py @@ -19,7 +19,7 @@ # bl_info = { - "name": "Hotkey: 'Tab'", + "name": "Hotkey: 'Ctrl Tab'", "description": "Switch between 3d view object/edit modes", "author": "pitiwazou, meta-androcto, italic", "version": (0, 1, 2), @@ -289,7 +289,7 @@ class PIE_MT_ObjectEditotherModes(Menu): class PIE_MT_ObjectEditMode(Menu): """Modes Switch""" bl_idname = "PIE_MT_objecteditmode" - bl_label = "Modes Menu (Tab)" + bl_label = "Mode Switch (Ctrl Tab)" def draw(self, context): layout = self.layout @@ -315,7 +315,7 @@ class PIE_MT_ObjectEditMode(Menu): # 2 - BOTTOM pie.menu("MENU_MT_objecteditmodeothermodes", text="Vert,Edge,Face Modes", icon='EDITMODE_HLT') # 8 - TOP - pie.operator("class.object", text="Edit/Object Toggle", icon='OBJECT_DATAMODE') + pie.operator("class.object", text="Object/Edit Toggle", icon='OBJECT_DATAMODE') # 7 - TOP - LEFT pie.operator("sculpt.sculptmode_toggle", text="Sculpt", icon='SCULPTMODE_HLT') # 9 - TOP - RIGHT @@ -492,7 +492,7 @@ classes = ( ) addon_keymaps = [] - + def register(): for cls in classes: @@ -502,12 +502,12 @@ def register(): if wm.keyconfigs.addon: # Select Mode km = wm.keyconfigs.addon.keymaps.new(name='Object Non-modal') - kmi = km.keymap_items.new('wm.call_menu_pie', 'TAB', 'PRESS') + kmi = km.keymap_items.new('wm.call_menu_pie', 'TAB', 'PRESS', ctrl=True) kmi.properties.name = "PIE_MT_objecteditmode" addon_keymaps.append((km, kmi)) km = wm.keyconfigs.addon.keymaps.new(name='Grease Pencil Stroke Edit Mode') - kmi = km.keymap_items.new('wm.call_menu_pie', 'TAB', 'PRESS') + kmi = km.keymap_items.new('wm.call_menu_pie', 'TAB', 'PRESS', ctrl=True) kmi.properties.name = "PIE_MT_objecteditmode" addon_keymaps.append((km, kmi)) diff --git a/space_view3d_pie_menus/pie_origin.py b/space_view3d_pie_menus/pie_origin.py index 377be27f..53448db2 100644 --- a/space_view3d_pie_menus/pie_origin.py +++ b/space_view3d_pie_menus/pie_origin.py @@ -19,10 +19,10 @@ # bl_info = { - "name": "Hotkey: 'Alt Shift O'", + "name": "Hotkey: 'Ctrl Alt X'", "description": "Origin Snap/Place Menu", "author": "pitiwazou, meta-androcto", - "version": (0, 1, 1), + "version": (0, 1, 2), "blender": (2, 80, 0), "location": "3D View", "warning": "", @@ -57,7 +57,6 @@ class PIE_OT_PivotToSelection(Operator): return {'FINISHED'} - # Pivot to Bottom class PIE_OT_PivotBottom(Operator): bl_idname = "object.pivotobottom" @@ -66,6 +65,39 @@ class PIE_OT_PivotBottom(Operator): "Needs an Active Object of the Mesh type") bl_options = {'REGISTER', 'UNDO'} + @classmethod + def poll(cls, context): + obj = context.active_object + return obj is not None and obj.type == "MESH" + + def execute(self, context): + bpy.ops.object.transform_apply(location=True, rotation=True, scale=True) + bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY') + o = context.active_object + init = 0 + for x in o.data.vertices: + if init == 0: + a = x.co.z + init = 1 + elif x.co.z < a: + a = x.co.z + + for x in o.data.vertices: + x.co.z -= a + + o.location.z += a + + return {'FINISHED'} + + +# Pivot to Bottom +class PIE_OT_PivotBottom_edit(Operator): + bl_idname = "object.pivotobottom_edit" + bl_label = "Pivot To Bottom" + bl_description = ("Set the Pivot Point To Lowest Point\n" + "Needs an Active Object of the Mesh type") + bl_options = {'REGISTER', 'UNDO'} + @classmethod def poll(cls, context): obj = context.active_object @@ -93,6 +125,118 @@ class PIE_OT_PivotBottom(Operator): return {'FINISHED'} +# Pivot to Cursor Edit Mode +class PIE_OT_PivotToCursor_edit(Operator): + bl_idname = "object.pivot2cursor_edit" + bl_label = "Pivot To Cursor" + bl_description = "Pivot Point To Cursor" + bl_options = {'REGISTER', 'UNDO'} + + @classmethod + def poll(cls, context): + return context.active_object is not None + + def execute(self, context): + bpy.ops.object.mode_set(mode='OBJECT') + bpy.ops.object.origin_set(type='ORIGIN_CURSOR') + bpy.ops.object.mode_set(mode='EDIT') + + return {'FINISHED'} + + +# Origin to Center of Mass Edit Mode +class PIE_OT_OriginToMass_edit(Operator): + bl_idname = "object.origintomass_edit" + bl_label = "Origin" + bl_description = "Origin to Center of Mass" + bl_options = {'REGISTER', 'UNDO'} + + @classmethod + def poll(cls, context): + return context.active_object is not None + + def execute(self, context): + bpy.ops.object.mode_set(mode='OBJECT') + bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_MASS', center='MEDIAN') + bpy.ops.object.mode_set(mode='EDIT') + + return {'FINISHED'} + + +# Origin to Geometry Edit Mode +class PIE_OT_OriginToGeometry_edit(Operator): + bl_idname = "object.origintogeometry_edit" + bl_label = "Origin to Geometry" + bl_description = "Origin to Geometry" + bl_options = {'REGISTER', 'UNDO'} + + @classmethod + def poll(cls, context): + return context.active_object is not None + + def execute(self, context): + bpy.ops.object.mode_set(mode='OBJECT') + bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN') + bpy.ops.object.mode_set(mode='EDIT') + + return {'FINISHED'} + + +# Origin to Geometry Edit Mode +class PIE_OT_GeometryToOrigin_edit(Operator): + bl_idname = "object.geometrytoorigin_edit" + bl_label = "Geometry to Origin" + bl_description = "Geometry to Origin" + bl_options = {'REGISTER', 'UNDO'} + + @classmethod + def poll(cls, context): + return context.active_object is not None + + def execute(self, context): + bpy.ops.object.mode_set(mode='OBJECT') + bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN', center='MEDIAN') + bpy.ops.object.mode_set(mode='EDIT') + + return {'FINISHED'} + + +# Origin To Selected Edit Mode # +def vfeOrigin_pie(context): + try: + cursorPositionX = context.scene.cursor.location[0] + cursorPositionY = context.scene.cursor.location[1] + cursorPositionZ = context.scene.cursor.location[2] + bpy.ops.view3d.snap_cursor_to_selected() + bpy.ops.object.mode_set() + bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='MEDIAN') + bpy.ops.object.mode_set(mode='EDIT') + context.scene.cursor.location[0] = cursorPositionX + context.scene.cursor.location[1] = cursorPositionY + context.scene.cursor.location[2] = cursorPositionZ + return True + except: + return False + + +class PIE_OT_SetOriginToSelected_edit(Operator): + bl_idname = "object.setorigintoselected_edit" + bl_label = "Set Origin to Selected" + bl_description = "Set Origin to Selected" + + @classmethod + def poll(cls, context): + return (context.area.type == "VIEW_3D" and context.active_object is not None) + + def execute(self, context): + check = vfeOrigin_pie(context) + if not check: + self.report({"ERROR"}, "Set Origin to Selected could not be performed") + return {'CANCELLED'} + + return {'FINISHED'} + + # Pie Origin/Pivot - Shift + S class PIE_MT_OriginPivot(Menu): bl_idname = "ORIGIN_MT_pivotmenu" @@ -102,12 +246,12 @@ class PIE_MT_OriginPivot(Menu): layout = self.layout obj = context.object pie = layout.menu_pie() - if obj and obj.type == 'MESH': + if obj and obj.type == 'MESH' and obj.mode in {'OBJECT'}: # 4 - LEFT pie.operator("object.origin_set", text="Origin to Center of Mass", icon='NONE').type = 'ORIGIN_CENTER_OF_MASS' # 6 - RIGHT - pie.operator("object.origin_set", text="Origin To 3D Cursor", + pie.operator("object.origin_set", text="Origin to Cursor", icon='PIVOT_CURSOR').type = 'ORIGIN_CURSOR' # 2 - BOTTOM pie.operator("object.pivotobottom", text="Origin to Bottom", @@ -122,6 +266,27 @@ class PIE_MT_OriginPivot(Menu): pie.operator("object.origin_set", text="Origin To Geometry", icon='NONE').type = 'ORIGIN_GEOMETRY' + + elif obj and obj.type == 'MESH' and obj.mode in {'EDIT'}: + # 4 - LEFT + pie.operator("object.origintomass_edit", text="Origin to Center of Mass", + icon='NONE') + # 6 - RIGHT + pie.operator("object.pivot2cursor_edit", text="Origin to Cursor", + icon='PIVOT_CURSOR') + # 2 - BOTTOM + pie.operator("object.pivotobottom_edit", text="Origin to Bottom", + icon='TRIA_DOWN') + # 8 - TOP + pie.operator("object.setorigintoselected_edit", text="Origin To Selected", + icon='SNAP_INCREMENT') + # 7 - TOP - LEFT + pie.operator("object.geometrytoorigin_edit", text="Geometry To Origin", + icon='NONE') + # 9 - TOP - RIGHT + pie.operator("object.origintogeometry_edit", text="Origin To Geometry", + icon='NONE') + else: # 4 - LEFT pie.operator("object.origin_set", text="Origin to Center of Mass", @@ -144,6 +309,12 @@ classes = ( PIE_MT_OriginPivot, PIE_OT_PivotToSelection, PIE_OT_PivotBottom, + PIE_OT_PivotToCursor_edit, + PIE_OT_OriginToMass_edit, + PIE_OT_PivotBottom_edit, + PIE_OT_OriginToGeometry_edit, + PIE_OT_GeometryToOrigin_edit, + PIE_OT_SetOriginToSelected_edit ) addon_keymaps = [] @@ -157,7 +328,7 @@ def register(): if wm.keyconfigs.addon: # Origin/Pivot km = wm.keyconfigs.addon.keymaps.new(name='3D View Generic', space_type='VIEW_3D') - kmi = km.keymap_items.new('wm.call_menu_pie', 'O', 'PRESS', shift=True, alt=True) + kmi = km.keymap_items.new('wm.call_menu_pie', 'X', 'PRESS', ctrl=True, alt=True) kmi.properties.name = "ORIGIN_MT_pivotmenu" addon_keymaps.append((km, kmi)) diff --git a/space_view3d_pie_menus/pie_proportional_menu.py b/space_view3d_pie_menus/pie_proportional_menu.py index 0350d829..10b4cf57 100644 --- a/space_view3d_pie_menus/pie_proportional_menu.py +++ b/space_view3d_pie_menus/pie_proportional_menu.py @@ -19,7 +19,7 @@ # bl_info = { - "name": "Hotkey: 'O'", + "name": "Hotkey: 'Shift O'", "description": "Proportional Object/Edit Tools", "author": "pitiwazou, meta-androcto", "version": (0, 1, 1), @@ -286,6 +286,16 @@ class PIE_OT_ProportionalRandomEdt(Operator): ts.proportional_edit_falloff = 'RANDOM' return {'FINISHED'} +class PIE_OT_ProportionalInverseS(Operator): + bl_idname = "proportional_edt.inverse" + bl_label = "Proportional Inverse Square" + bl_options = {'REGISTER', 'UNDO'} + + def execute(self, context): + ts = context.tool_settings + ts.use_proportional_edit = True + ts.proportional_edit_falloff = 'INVERSE_SQUARE' + return {'FINISHED'} # Pie ProportionalEditObj - O class PIE_MT_ProportionalObj(Menu): @@ -326,13 +336,13 @@ class PIE_MT_ProportionalEdt(Menu): # 6 - RIGHT pie.operator("proportional_edt.projected", text="Projected", icon='PROP_ON') # 2 - BOTTOM - pie.operator("proportional_edt.smooth", text="Smooth", icon='SMOOTHCURVE') + pie.operator("proportional_edt.root", text="Root", icon='ROOTCURVE') # 8 - TOP pie.operator("proportional_edt.active", text="Proportional On/Off", icon='PROP_ON') # 7 - TOP - LEFT - pie.operator("proportional_edt.sphere", text="Sphere", icon='SPHERECURVE') + pie.operator("proportional_edt.smooth", text="Smooth", icon='SMOOTHCURVE') # 9 - TOP - RIGHT - pie.operator("proportional_edt.root", text="Root", icon='ROOTCURVE') + pie.operator("proportional_edt.sphere", text="Sphere", icon='SPHERECURVE') # 1 - BOTTOM - LEFT pie.operator("proportional_edt.constant", text="Constant", icon='NOCURVE') # 3 - BOTTOM - RIGHT @@ -351,6 +361,7 @@ class PIE_MT_ProportionalMore(Menu): box.operator("proportional_edt.linear", text="Linear", icon='LINCURVE') box.operator("proportional_edt.sharp", text="Sharp", icon='SHARPCURVE') box.operator("proportional_edt.random", text="Random", icon='RNDCURVE') + box.operator("proportional_edt.inverse", text="INVERSE", icon='INVERSESQUARECURVE') classes = ( @@ -375,6 +386,7 @@ classes = ( PIE_MT_ProportionalObj, PIE_MT_ProportionalEdt, PIE_MT_ProportionalMore, + PIE_OT_ProportionalInverseS, ) addon_keymaps = [] @@ -388,13 +400,13 @@ def register(): if wm.keyconfigs.addon: # ProportionalEditObj km = wm.keyconfigs.addon.keymaps.new(name='Object Mode') - kmi = km.keymap_items.new('wm.call_menu_pie', 'O', 'PRESS') + kmi = km.keymap_items.new('wm.call_menu_pie', 'O', 'PRESS', shift=True) kmi.properties.name = "PIE_MT_proportional_obj" addon_keymaps.append((km, kmi)) # ProportionalEditEdt km = wm.keyconfigs.addon.keymaps.new(name='Mesh') - kmi = km.keymap_items.new('wm.call_menu_pie', 'O', 'PRESS') + kmi = km.keymap_items.new('wm.call_menu_pie', 'O', 'PRESS', shift=True) kmi.properties.name = "PIE_MT_proportional_edt" addon_keymaps.append((km, kmi)) diff --git a/space_view3d_pie_menus/pie_save_open_menu.py b/space_view3d_pie_menus/pie_save_open_menu.py index 354c40e6..29fe67a2 100644 --- a/space_view3d_pie_menus/pie_save_open_menu.py +++ b/space_view3d_pie_menus/pie_save_open_menu.py @@ -191,7 +191,7 @@ def register(): wm = bpy.context.window_manager if wm.keyconfigs.addon: # Save/Open/... - km = wm.keyconfigs.addon.keymaps.new(name='Window') + km = wm.keyconfigs.addon.keymaps.new(name='Object Non-modal') kmi = km.keymap_items.new('wm.call_menu_pie', 'S', 'PRESS', ctrl=True) kmi.properties.name = "PIE_MT_saveopen" addon_keymaps.append((km, kmi)) diff --git a/space_view3d_pie_menus/pie_views_numpad_menu.py b/space_view3d_pie_menus/pie_views_numpad_menu.py index 58d5749a..eb9f85b6 100644 --- a/space_view3d_pie_menus/pie_views_numpad_menu.py +++ b/space_view3d_pie_menus/pie_views_numpad_menu.py @@ -19,12 +19,12 @@ # bl_info = { - "name": "Hotkey: 'Q'", + "name": "Hotkey: 'Alt Q'", "description": "Viewport Numpad Menus", "author": "pitiwazou, meta-androcto", "version": (0, 1, 1), "blender": (2, 80, 0), - "location": "Q key", + "location": "Alt Q key", "warning": "", "wiki_url": "", "category": "View Numpad Pie" @@ -70,35 +70,10 @@ class PIE_OT_LockTransforms(Operator): return {'FINISHED'} -# Pie View All Sel Glob Etc - Q -class PIE_MT_ViewallSelGlobEtc(Menu): - bl_idname = "PIE_MT_vieallselglobetc" - bl_label = "Pie View All Sel Glob..." - - def draw(self, context): - layout = self.layout - - # 4 - LEFT - layout.operator("view3d.view_all", text="View All").center = True - # 6 - RIGHT - layout.operator("view3d.view_selected", text="View Selected") - # 2 - BOTTOM - layout.operator("view3d.view_persportho", text="Persp/Ortho", icon='RESTRICT_VIEW_OFF') - # 8 - TOP - layout.operator("view3d.localview", text="Local/Global") - # 7 - TOP - LEFT - layout.operator("screen.region_quadview", text="Toggle Quad View", icon='NONE') - # 1 - BOTTOM - LEFT - layout.operator("wm.call_menu_pie", text="Previous Menu", icon='BACK').name = "PIE_MT_viewnumpad" - # 9 - TOP - RIGHT - layout.operator("screen.screen_full_area", text="Full Screen", icon='FULLSCREEN_ENTER') - # 3 - BOTTOM - RIGHT - - # Pie views numpad - Q class PIE_MT_ViewNumpad(Menu): bl_idname = "PIE_MT_viewnumpad" - bl_label = "Pie Views Ortho" + bl_label = "Pie Views Menu" def draw(self, context): layout = self.layout @@ -116,24 +91,24 @@ class PIE_MT_ViewNumpad(Menu): # 8 - TOP pie.operator("view3d.view_axis", text="Top", icon='TRIA_UP').type = 'TOP' # 7 - TOP - LEFT - pie.operator("view3d.view_axis", text="Front").type = 'FRONT' - # 9 - TOP - RIGHT pie.operator("view3d.view_axis", text="Back").type = 'BACK' + # 9 - TOP - RIGHT + pie.operator("view3d.view_axis", text="Front").type = 'FRONT' # 1 - BOTTOM - LEFT box = pie.split().column() + row = box.row(align=True) + row.operator("view3d.view_camera", text="View Cam", icon='HIDE_OFF') + row.operator("view3d.camera_to_view", text="Cam To View", icon='NONE') + row = box.row(align=True) if context.space_data.lock_camera is False: - row.operator("wm.context_toggle", text="Lock Cam to View", + row.operator("wm.context_toggle", text="Lock Cam To View", icon='UNLOCKED').data_path = "space_data.lock_camera" elif context.space_data.lock_camera is True: row.operator("wm.context_toggle", text="Lock Cam to View", icon='LOCKED').data_path = "space_data.lock_camera" - row = box.row(align=True) - row.operator("view3d.view_camera", text="View Cam", icon='HIDE_OFF') - row.operator("view3d.camera_to_view", text="Cam to view", icon='NONE') - icon_locked = 'LOCKED' if ob and ob.lock_rotation[0] is False else \ 'UNLOCKED' if ob and ob.lock_rotation[0] is True else 'LOCKED' @@ -143,13 +118,24 @@ class PIE_MT_ViewNumpad(Menu): row = box.row(align=True) row.prop(rd, "use_border", text="Border") # 3 - BOTTOM - RIGHT - pie.menu(PIE_MT_ViewallSelGlobEtc.bl_idname, text="View Menu", icon='NONE') + box = pie.split().column() + + row = box.row(align=True) + row.operator("view3d.view_all", text="View All").center = True + row.operator("view3d.view_selected", text="Selected") + + row = box.row(align=True) + row.operator("view3d.view_persportho", text="Persp/Ortho") + row.operator("view3d.localview", text="Local/Global") + + row = box.row(align=True) + row.operator("screen.region_quadview", text="Toggle Quad") + row.operator("screen.screen_full_area", text="Toggle Full") classes = ( PIE_MT_ViewNumpad, PIE_OT_LockTransforms, - PIE_MT_ViewallSelGlobEtc, ) addon_keymaps = [] @@ -163,7 +149,7 @@ def register(): if wm.keyconfigs.addon: # Views numpad km = wm.keyconfigs.addon.keymaps.new(name='3D View Generic', space_type='VIEW_3D') - kmi = km.keymap_items.new('wm.call_menu_pie', 'Q', 'PRESS') + kmi = km.keymap_items.new('wm.call_menu_pie', 'Q', 'PRESS', alt=True) kmi.properties.name = "PIE_MT_viewnumpad" addon_keymaps.append((km, kmi)) -- cgit v1.2.3