-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathexport_menu.py
295 lines (236 loc) · 9.49 KB
/
export_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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
import bpy
from bpy.props import IntProperty, BoolProperty, FloatProperty, EnumProperty, PointerProperty, StringProperty, CollectionProperty
from bpy.types import Menu, Operator
from .tk_utils import search as search_utils
from . import tk_utils
class CAPSULE_OT_PieWarning(Operator):
bl_idname = "capsule.pie_warning"
bl_label = ""
label: StringProperty(default = "")
def execute(self, context):
self.report({'WARNING'}, self.label)
return {"FINISHED"}
class CAPSULE_OT_ToggleExport(Operator):
bl_idname = "capsule.toggle_export"
bl_label = "Toggle Export"
export_type: StringProperty()
enabled: BoolProperty()
def execute(self, context):
#print("*" * 40)
scn = context.scene.CAPScn
proxy = context.scene.CAPProxy
sel = context.selected_objects
if self.export_type == "OBJECT":
proxy.obj_enable_export = self.enabled
else:
proxy.col_enable_export = self.enabled
return {'FINISHED'}
class CAPSULE_OT_LocationSelectObject(Operator):
bl_idname = "capsule.location_select_object"
bl_label = "Toggle Export"
loc: IntProperty(default=-1)
def execute(self, context):
if self.loc != -1:
proxy = context.scene.CAPProxy
proxy.obj_location_preset = str(self.loc + 1)
return {'FINISHED'}
class CAPSULE_OT_LocationSelectCollection(Operator):
bl_idname = "capsule.location_select_collection"
bl_label = "Toggle Export"
loc: IntProperty(default=-1)
def execute(self, context):
if self.loc != -1:
proxy = context.scene.CAPProxy
proxy.col_location_preset = str(self.loc + 1)
return {'FINISHED'}
class CAPSULE_MT_PieLocationObject(Menu):
"""
Shows the currently available locations that can be assigned to an object export.
"""
bl_idname = "pie.location_object"
bl_label = "Select Location"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
obj = context.object.CAPObj
preferences = context.preferences
addon_prefs = preferences.addons[__package__].preferences
cap_file = bpy.data.objects[addon_prefs.default_datablock].CAPFile
i = 0
for loc in cap_file.location_presets:
pie.operator("capsule.location_select_object", text=cap_file.location_presets[i].name, icon = "FILE_FOLDER").loc = i
i += 1
class CAPSULE_MT_PieLocationCollection(Menu):
"""
Shows the currently available locations that can be assigned to an collection export.
"""
bl_idname = "pie.location_collection"
bl_label = "Select Location"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
obj = context.object.CAPObj
preferences = context.preferences
addon_prefs = preferences.addons[__package__].preferences
cap_file = bpy.data.objects[addon_prefs.default_datablock].CAPFile
i = 0
for loc in cap_file.location_presets:
pie.operator("capsule.location_select_collection", text=cap_file.location_presets[i].name, icon = "FILE_FOLDER").loc = i
i += 1
class CAPSULE_OT_ExportSelectObject(Operator):
"""
A pie-specific operator for toggling the export status of the currently selected objects.
"""
bl_idname = "capsule.export_select_object"
bl_label = "Toggle Export"
loc: IntProperty(default=-1)
def execute(self, context):
if self.loc != -1:
proxy = context.scene.CAPProxy
proxy.obj_export_preset = str(self.loc + 1)
return {'FINISHED'}
class CAPSULE_OT_ExportSelectCollection(Operator):
"""
A pie-specific operator for toggling the export status of the currently selected collections.
"""
bl_idname = "capsule.export_select_collection"
bl_label = "Toggle Export"
loc: IntProperty(default=-1)
def execute(self, context):
if self.loc != -1:
proxy = context.scene.CAPProxy
proxy.col_export_preset = str(self.loc + 1)
return {'FINISHED'}
class CAPSULE_MT_PieExportObject(Menu):
"""
Shows the currently available export presets that can be assigned to an object export.
"""
bl_idname = "pie.export_object"
bl_label = "Select Location"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
obj = context.object.CAPObj
preferences = context.preferences
addon_prefs = preferences.addons[__package__].preferences
cap_file = bpy.data.objects[addon_prefs.default_datablock].CAPFile
i = 0
for loc in cap_file.export_presets:
pie.operator("capsule.export_select_object", text=cap_file.export_presets[i].name, icon = "PREFERENCES").loc = i
i += 1
class CAPSULE_MT_PieExportCollection(Menu):
"""
Shows the currently available export presets that can be assigned to a collection export.
"""
bl_idname = "pie.export_collection"
bl_label = "Select Location"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
obj = context.object.CAPObj
preferences = context.preferences
addon_prefs = preferences.addons[__package__].preferences
cap_file = bpy.data.objects[addon_prefs.default_datablock].CAPFile
i = 0
for loc in cap_file.export_presets:
pie.operator("capsule.export_select_collection", text=cap_file.export_presets[i].name, icon = "PREFERENCES").loc = i
i += 1
class CAPSULE_OT_PieObjectMenu(Menu):
"""
Pie menus to display object-specific Capsule options and settings.
"""
bl_idname = "pie.capsule_object"
bl_label = "Capsule Object Settings"
@classmethod
def poll(cls, context):
has_sel = False
if len(context.selected_objects) > 0:
has_sel = True
return has_sel
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
# 4 - LEFT
enable_export = pie.operator("capsule.toggle_export", text= "Enable Export", icon = "ADD")
enable_export.export_type = "OBJECT"
enable_export.enabled = True
# 6 - RIGHT
disable_export = pie.operator("capsule.toggle_export", text= "Disable Export", icon = "X")
disable_export.export_type = "OBJECT"
disable_export.enabled = False
# 2 - BOTTOM
pie.operator("wm.call_menu_pie", text= "Set Location", icon = "FILE_FOLDER").name = "pie.location_object"
# 8 - TOP
pie.operator("wm.call_menu_pie", text= "Set Export Preset", icon = "PREFERENCES").name = "pie.export_object"
# 7 - TOP - LEFT
# 1 - BOTTOM - LEFT
# 9 - TOP - RIGHT
# 3 - BOTTOM - RIGHT
class CAPSULE_OT_PieCollectionMenu(Menu):
"""
Pie menus to display collection-specific Capsule options and settings.
"""
bl_idname = "pie.capsule_collection"
bl_label = "Capsule Collection Settings"
@classmethod
def poll(cls, context):
has_sel = False
if len(context.selected_objects) > 0:
has_sel = True
return has_sel
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
# 4 - LEFT
enable_export = pie.operator("capsule.toggle_export", text= "Enable Export", icon = "ADD")
enable_export.export_type = "COLLECTION"
enable_export.enabled = True
# 6 - RIGHT
disable_export = pie.operator("capsule.toggle_export", text= "Disable Export", icon = "X")
disable_export.export_type = "COLLECTION"
disable_export.enabled = False
# 2 - BOTTOM
pie.operator("wm.call_menu_pie", text= "Set Location", icon = "FILE_FOLDER").name = "pie.location_collection"
# 8 - TOP
pie.operator("wm.call_menu_pie", text= "Set Export Preset", icon = "PREFERENCES").name = "pie.export_collection"
# 7 - TOP - LEFT
# 1 - BOTTOM - LEFT
# 9 - TOP - RIGHT
# 3 - BOTTOM - RIGHT
class CAPSULE_OT_PieExport(Menu):
"""
Pie menus for the base menu that appears when E is used.
"""
bl_idname = "pie.capsule_export"
bl_label = "Export..."
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
# 4 - LEFT
pie.operator("scene.cap_export", text= "Export All", icon = "EXPORT").set_mode = 'ALL'
# 6 - RIGHT
pie.operator("scene.cap_export", text= "Export Selected", icon = "EXPORT").set_mode = 'SELECTED_ALL'
# 2 - BOTTOM
# 8 - TOP
# 7 - TOP - LEFT
# 1 - BOTTOM - LEFT
# 9 - TOP - RIGHT
# 3 - BOTTOM - RIGHT
class CAPSULE_OT_PieMainMenu(Menu):
"""
Pie menus for the base menu that appears when E is used.
"""
bl_idname = "pie.capsule_main"
bl_label = "Capsule Export Menu"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
has_sel = False
if len(context.selected_objects) > 0:
pie.operator("wm.call_menu_pie", text= "Object Settings", icon = "OBJECT_DATA").name = "pie.capsule_object"
# 6 - RIGHT
pie.operator("wm.call_menu_pie", text= "Collection Settings", icon = "GROUP").name = "pie.capsule_collection"
# 2 - BOTTOM
pie.operator("wm.call_menu_pie", text= "Export with Capsule", icon = "EXPORT").name = "pie.capsule_export"
else:
pie.operator("wm.call_menu_pie", text= "Export with Capsule", icon = "EXPORT").name = "pie.capsule_export"