Skip to content

Commit

Permalink
feat: add keymaps for difference, union, intersect, and slice boolean…
Browse files Browse the repository at this point in the history
… operations
  • Loading branch information
tristan-hm committed Jun 18, 2023
1 parent 3e55ba0 commit 402857d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,15 +547,15 @@ def draw_keymap(self, box):
wm = bpy.context.window_manager
kc = wm.keyconfigs.user

for keymap in ['3D View', 'Mesh', 'Object Mode']:
for keymap in ['Mesh', 'Object Mode']:
km = kc.keymaps.get(keymap)

column = box.column(align=True)
row = column.row()
row.label(text=keymap)

for kmi in km.keymap_items:
if kmi.idname == "wm.call_menu" and kmi.name.startswith(name):
if (kmi.idname == "wm.call_menu" and kmi.name.startswith(name)) or kmi.idname.startswith("nd."):
column = box.column(align=True)
row = column.row()
rna_keymap_ui.draw_kmi(["ADDON", "USER", "DEFAULT"], kc, km, kmi, row, 0)
Expand Down
13 changes: 13 additions & 0 deletions booleans/boolean_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
from .. lib.modifiers import new_modifier, remove_problematic_bevels


keys = []


class ND_OT_bool_slice(bpy.types.Operator):
bl_idname = "nd.bool_slice"
bl_label = "Slice"
Expand Down Expand Up @@ -94,6 +97,16 @@ def invoke(self, context, event):
def register():
bpy.utils.register_class(ND_OT_bool_slice)

for mapping in [('Mesh', 'EMPTY'), ('Object Mode', 'EMPTY')]:
keymap = bpy.context.window_manager.keyconfigs.addon.keymaps.new(name=mapping[0], space_type=mapping[1])
entry = keymap.keymap_items.new("nd.bool_slice", 'NUMPAD_SLASH', 'PRESS', ctrl = True)
keys.append((keymap, entry))


def unregister():
for keymap, entry in keys:
keymap.keymap_items.remove(entry)

keys.clear()

bpy.utils.unregister_class(ND_OT_bool_slice)
23 changes: 23 additions & 0 deletions booleans/vanilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
from .. lib.modifiers import new_modifier, remove_problematic_bevels


keys = []


class ND_OT_bool_vanilla(bpy.types.Operator):
bl_idname = "nd.bool_vanilla"
bl_label = "Boolean"
Expand Down Expand Up @@ -90,6 +93,26 @@ def invoke(self, context, event):
def register():
bpy.utils.register_class(ND_OT_bool_vanilla)

for mapping in [('Mesh', 'EMPTY'), ('Object Mode', 'EMPTY')]:
keymap = bpy.context.window_manager.keyconfigs.addon.keymaps.new(name=mapping[0], space_type=mapping[1])

entry = keymap.keymap_items.new("nd.bool_vanilla", 'NUMPAD_MINUS', 'PRESS', ctrl = True)
entry.properties.mode = "DIFFERENCE"
keys.append((keymap, entry))

entry = keymap.keymap_items.new("nd.bool_vanilla", 'NUMPAD_PLUS', 'PRESS', ctrl = True)
entry.properties.mode = "UNION"
keys.append((keymap, entry))

entry = keymap.keymap_items.new("nd.bool_vanilla", 'NUMPAD_ASTERIX', 'PRESS', ctrl = True)
entry.properties.mode = "INTERSECT"
keys.append((keymap, entry))


def unregister():
for keymap, entry in keys:
keymap.keymap_items.remove(entry)

keys.clear()

bpy.utils.unregister_class(ND_OT_bool_vanilla)

0 comments on commit 402857d

Please sign in to comment.