-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathexport_presets.py
135 lines (105 loc) · 3.67 KB
/
export_presets.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
import bpy
import copy
from bpy.types import Operator
from bpy.props import IntProperty, BoolProperty, FloatProperty, EnumProperty, PointerProperty, StringProperty, CollectionProperty
def DeletePresets():
"""
Removes all Export Presets that that can be deleted by the user from the saved presets list.
"""
#print(">>>>>>>>>> Deleting presets...")
preferences = bpy.context.preferences
addon_prefs = preferences.addons[__package__].preferences
cap_file = addon_prefs.saved_export_presets
presetsToKeep = []
i = len(cap_file) - 1
#print("i = ", i)
while i != -1:
item = cap_file[i]
#print("item = ", item)
if item.x_global_user_deletable is False:
#print("Removing default cap_file...", cap_file[i])
cap_file.remove(i)
i -= 1
def CreatePresets():
"""
Generates a list of saved presets based on pre-made templates.
"""
# -------------------------------------------------------------------------
# Basic Export All
# -------------------------------------------------------------------------
preferences = bpy.context.preferences
addon_prefs = preferences.addons[__package__].preferences
cap_file = addon_prefs.saved_export_presets
sort = addon_prefs.sort_presets
#print(">>>>>>>>>> Adding presets...")
# Erase the previous sort entries (delayed)
#print("Clearing sort presets")
x = 0
lenX = len(sort)
while x < lenX:
#print("Deleting sort preset...", sort[0])
sort.remove(0)
x += 1
# Copy all the currently-saved presets to a temporary sort preset location.
i = 0
lenI = len(cap_file)
#print("lenI = ", lenI)
#print("lenI = ", lenI)
#print("lenI = ", lenI)
while i < lenI:
if cap_file[0].x_global_user_deletable is True:
#print("Copying user-defined preset...", cap_file[0])
newPreset = sort.add()
CopyPreset(cap_file[0], newPreset)
#print("Deleting preset...", cap_file[0])
cap_file.remove(0)
i += 1
# Create the new presets
# CreatePresetDemo(cap_file)
# Add the copied presets back
i = 0
lenI = len(sort)
#print(sort)
while i < lenI:
#print("Adding back preset...", sort[0])
newPreset = cap_file.add()
CopyPreset(sort[0], newPreset)
sort.remove(0)
i += 1
def CreatePresetDemo(cap_file):
"""
Generates a saved preset for exporting UE4-compatible assets.
"""
# -------------------------------------------------------------------------
# UE4 Standard Template
# -------------------------------------------------------------------------
export = cap_file.add()
export.name = "Default Export Preset Demo"
export.description = "Creates a tooltip for the preset."
export.x_global_user_deletable = False
# add options here!
def CopyPreset(old_preset, new_preset):
"""
Copies all the properties of one property into another given property.
"""
for key in old_preset.keys():
new_preset[key] = old_preset[key]
class CAPSULE_OT_DrawError(Operator):
"""
???
"""
bl_idname = "cap.draw_error"
bl_label = "Store Preset"
title = StringProperty()
message = StringProperty()
def execute(self, context):
bpy.context.window_manager.popup_menu(self.draw(context), title=self.title, icon= 'INFO')
return {'FINISHED'}
def draw(self, context):
layout = self.layout
col = layout.column()
col.label(text= "Custom Interface!")
row = col.row()
row.prop(self, "my_float")
row.prop(self, "my_bool")
col.prop(self, "my_string")