forked from wheybags/freeablo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dyntopo_menu.py
68 lines (50 loc) · 2.28 KB
/
dyntopo_menu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from bpy.props import *
from .Utils.core import *
class DynTopoMenu(bpy.types.Menu):
bl_label = "Dyntopo"
bl_idname = "VIEW3D_MT_dyntopo"
@classmethod
def poll(self, context):
if get_mode() == sculpt:
return True
else:
return False
def draw(self, context):
menu = Menu(self)
if context.object.use_dynamic_topology_sculpting:
menu.add_item().operator("sculpt.dynamic_topology_toggle", "Disable Dynamic Topology")
menu.add_item().separator()
menu.add_item().operator("sculpt.optimize")
if bpy.context.tool_settings.sculpt.detail_type_method == 'CONSTANT':
menu.add_item().operator("sculpt.detail_flood_fill")
menu.add_item().menu(SymmetrizeMenu.bl_idname)
else:
menu.add_item()
menu.current_item.operator_context = 'INVOKE_DEFAULT'
menu.current_item.operator("sculpt.dynamic_topology_toggle", "Enable Dynamic Topology")
class SymmetrizeMenu(bpy.types.Menu):
bl_label = "Symmetrize"
bl_idname = "VIEW3D_MT_symmetrize_menu"
def draw(self, context):
menu = Menu(self)
path = "tool_settings.sculpt.symmetrize_direction"
# add the the symmetrize operator to the menu
menu.add_item().operator("sculpt.symmetrize")
menu.add_item().separator()
# add the rest of the menu items
for item in context.tool_settings.sculpt.bl_rna.properties['symmetrize_direction'].enum_items:
menuprop(menu.add_item(), item.name, item.identifier, path, disable=True,
icon='RADIOBUT_OFF', disable_icon='RADIOBUT_ON')
### ------------ New hotkeys and registration ------------ ###
addon_keymaps = []
def register():
wm = bpy.context.window_manager
km = wm.keyconfigs.addon.keymaps.new(name='Sculpt')
kmi = km.keymap_items.new('wm.call_menu', 'D', 'PRESS', ctrl=True)
kmi.properties.name = 'VIEW3D_MT_dyntopo'
addon_keymaps.append((km, kmi))
def unregister():
# remove keymaps when add-on is deactivated
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()