-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy path__init__.py
164 lines (119 loc) · 5.53 KB
/
__init__.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
bl_info = {
"name": "EdgeFlow",
"category": "Mesh",
"author": "Benjamin Sauder",
"description": "Helps adjusting geometry to curved surfaces",
"version": (0, 8),
"location": "Mesh > Edge > Set Edge Flow",
"blender": (3, 5, 1),
"tracker_url": "https://github.com/BenjaminSauder/EdgeFlow/issues",
"wiki_url": "https://github.com/BenjaminSauder/EdgeFlow" ,
}
if "bpy" in locals():
import importlib
importlib.reload(util)
importlib.reload(edgeloop)
importlib.reload(interpolate)
importlib.reload(op_set_edge_flow)
importlib.reload(op_set_edge_linear)
importlib.reload(op_set_edge_curve)
importlib.reload(op_set_vertex_curve)
else:
from . import (
util,
interpolate,
edgeloop,
op_set_edge_flow,
op_set_edge_linear,
op_set_edge_curve,
op_set_vertex_curve,
)
import bpy
from bpy.types import Menu
from bpy.props import BoolProperty, EnumProperty
def menu_func_edges(self, context):
layout = self.layout
layout.separator()
layout.operator_context = "INVOKE_DEFAULT"
layout.operator(op_set_edge_flow.SetEdgeFlowOP.bl_idname, text='Set Flow')
layout.operator(op_set_edge_curve.SetEdgeCurveOP.bl_idname, text='Set Curve')
layout.operator(op_set_edge_linear.SetEdgeLinearOP.bl_idname, text='Set Linear')
def menu_func_vertices(self, context):
layout = self.layout
layout.separator()
layout.operator_context = "INVOKE_DEFAULT"
layout.operator(op_set_vertex_curve.SetVertexCurveOp.bl_idname, text='Set Vertex Curve')
list_insertion_options = [
("BOTTOM", "Bottom of Menu", "", 1),
("TOP", "Top of menu", "", 2),
]
def on_preferences_update(self, context):
preferences = bpy.context.preferences.addons[__package__].preferences
bpy.types.VIEW3D_MT_edit_mesh_context_menu.remove(menu_func_context_menu)
if preferences.add_to_rightclick_menu:
if preferences.list_insertion_choice == 'BOTTOM':
bpy.types.VIEW3D_MT_edit_mesh_context_menu.append(menu_func_context_menu)
else:
bpy.types.VIEW3D_MT_edit_mesh_context_menu.prepend(menu_func_context_menu)
class Preferences(bpy.types.AddonPreferences):
bl_idname = __package__
add_to_rightclick_menu: BoolProperty(name="Extend rightlick menu", default=True, update=on_preferences_update)
list_insertion_choice: EnumProperty(name="Add at", items=list_insertion_options, default=2, update=on_preferences_update)
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False # No animation.
layout.label(text="UI Options")
col = layout.column(heading="Add commands to rightlick menu")
col.prop(self, "add_to_rightclick_menu", text="")
row = col.row()
row.prop(self, "list_insertion_choice")
row.enabled = self.add_to_rightclick_menu
class VIEW3D_MT_edit_mesh_set_flow(Menu):
bl_label = "Set Flow"
def draw(self, context):
layout = self.layout
mesh_select_mode = context.scene.tool_settings.mesh_select_mode[:3]
if mesh_select_mode == (True, False, False):
layout.operator(op_set_vertex_curve.SetVertexCurveOp.bl_idname, text='Set Vertex Curve')
elif mesh_select_mode == (False, True, False):
layout.operator(op_set_edge_flow.SetEdgeFlowOP.bl_idname, text='Set Flow')
layout.operator(op_set_edge_curve.SetEdgeCurveOP.bl_idname, text='Set Curve')
layout.operator(op_set_edge_linear.SetEdgeLinearOP.bl_idname, text='Set Linear')
def menu_func_context_menu(self, context):
preferences = bpy.context.preferences.addons[__package__].preferences
mesh_select_mode = context.scene.tool_settings.mesh_select_mode[:3]
if mesh_select_mode == (True, False, False) or mesh_select_mode == (False, True, False):
if preferences.list_insertion_choice == 'BOTTOM':
self.layout.separator()
self.layout.menu("VIEW3D_MT_edit_mesh_set_flow")
if preferences.list_insertion_choice == 'TOP':
self.layout.separator()
# stuff which needs to be registered in blender
classes = [
Preferences,
op_set_edge_flow.SetEdgeFlowOP,
op_set_edge_linear.SetEdgeLinearOP,
op_set_edge_curve.SetEdgeCurveOP,
op_set_vertex_curve.SetVertexCurveOp,
VIEW3D_MT_edit_mesh_set_flow,
]
def register():
for c in classes:
bpy.utils.register_class(c)
preferences = bpy.context.preferences.addons[__package__].preferences
bpy.types.VIEW3D_MT_edit_mesh_edges.append(menu_func_edges)
bpy.types.VIEW3D_MT_edit_mesh_vertices.append(menu_func_vertices)
if preferences.add_to_rightclick_menu:
if preferences.list_insertion_choice == 'BOTTOM':
bpy.types.VIEW3D_MT_edit_mesh_context_menu.append(menu_func_context_menu)
else:
bpy.types.VIEW3D_MT_edit_mesh_context_menu.prepend(menu_func_context_menu)
def unregister():
preferences = bpy.context.preferences.addons[__package__].preferences
if preferences.add_to_rightclick_menu:
bpy.types.VIEW3D_MT_edit_mesh_context_menu.remove(menu_func_context_menu)
bpy.types.VIEW3D_MT_edit_mesh_edges.remove(menu_func_edges)
bpy.types.VIEW3D_MT_edit_mesh_vertices.remove(menu_func_vertices)
for c in classes:
bpy.utils.unregister_class(c)