-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path__init__.py
268 lines (240 loc) · 8.13 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
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
# Copyright (C) 2022 Daniel Boxer
#
# BlenDir is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BlenDir is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BlenDir. If not, see <https://www.gnu.org/licenses/>.
bl_info = {
"name": "BlenDir",
"author": "Daniel Boxer",
"description": "Automatic folder structure",
"blender": (2, 90, 0),
"version": (0, 19, 2),
"location": (
"View3D > Sidebar > Tool & Properties > Active Tool and Workspace settings"
),
"category": "System",
"doc_url": "https://github.com/DanielBoxer/BlenDir#readme",
"tracker_url": "https://github.com/DanielBoxer/BlenDir/issues",
}
import pathlib
import bpy
from bpy.props import BoolProperty, EnumProperty, IntProperty, StringProperty
from .src.blendir_ui import (
BLENDIR_MT_bookmarks_pie,
BLENDIR_MT_recent_pie,
BLENDIR_MT_references_pie,
BLENDIR_PT_main,
draw_prefs,
)
from .src.bookmark import BLENDIR_PG_bookmark
from .src.ops.blendir_ops import (
BLENDIR_OT_directory_browser,
BLENDIR_OT_open_preferences,
BLENDIR_OT_open_reference,
BLENDIR_OT_reset_props,
BLENDIR_OT_save_blend,
BLENDIR_OT_save_panel_category,
BLENDIR_OT_start,
)
from .src.ops.bookmark_ops import (
BLENDIR_OT_bookmarks,
BLENDIR_OT_change_page,
BLENDIR_OT_edit_bookmarks,
BLENDIR_OT_open_bookmark,
BLENDIR_OT_open_bookmarks_pie,
)
from .src.ops.recent_ops import BLENDIR_OT_edit_recent, BLENDIR_OT_open_recent
from .src.ops.render_ops import BLENDIR_OT_render_animation, BLENDIR_OT_render_image
from .src.ops.structure_ops import (
BLENDIR_OT_delete_structure,
BLENDIR_OT_edit_structure,
BLENDIR_OT_import_structure,
BLENDIR_OT_new_structure,
)
from .src.structure import init_structs, update_structs
class BLENDIR_PG_properties(bpy.types.PropertyGroup):
# non UI properties
old_path: StringProperty()
reference_path: StringProperty()
render_path: StringProperty()
bookmark_page: IntProperty()
class BLENDIR_AP_preferences(bpy.types.AddonPreferences):
bl_idname = pathlib.Path(__file__).parent.stem
struct_data = init_structs()
struct_items = struct_data[0]
struct_icon = struct_data[1]
structure: EnumProperty(name="", description="Structure", items=update_structs)
# the previous save location
last_path: StringProperty()
# input properties
x_input: StringProperty(
name="", description="If a line has '*X', it will be replaced with this field"
)
y_input: StringProperty(
name="", description="If a line has '*Y', it will be replaced with this field"
)
z_input: StringProperty(
name="", description="If a line has '*Z', it will be replaced with this field"
)
# date time properties
date_format: EnumProperty(
name="",
description="If a line has '*D', it will be replaced with the current date",
items=[
("YMD", "YYYY/MM/DD", ""),
("MDY", "MM/DD/YYYY", ""),
("DMY", "DD/MM/YYYY", ""),
],
)
time_format: EnumProperty(
name="",
description="Time format for image renders",
items=[
("HMS", "HH/MM/SS", ""),
("MS", "MM/SS", ""),
],
)
date_separator: EnumProperty(
name="",
description="The character used to separate the year, month and day",
items=[
("-", "Dash", ""),
("_", "Underscore", ""),
(" ", "None", ""),
],
)
# misc properties
show_del_warning: BoolProperty(
name="Delete Structure",
description=(
"To delete a structure, the user first has to type 'delete' in the popup"
),
default=True,
)
show_create_warning: BoolProperty(
name="Create Folders",
description="Show a warning before creating folders after the first time",
default=True,
)
# animation folders properties
make_frames_folder: BoolProperty(
name="Make Folder for Frames",
description=(
"Make a subfolder in the render folder to hold all the animation folders"
),
default=True,
)
make_animation_folders: BoolProperty(
name="Make Animation Folders",
description=(
"Make a new folder for each animation render and save the frames there"
),
default=True,
)
# misc properties
autoload_refs: BoolProperty(
name="Autoload References",
description=(
"When opening a project from the 'Recent' menu, "
"open all references in the reference folder"
),
default=True,
)
verbose_ui: BoolProperty(
name="Verbose UI",
description=("Show text beside buttons in the main panel"),
default=False,
)
panel_category: StringProperty(
name="Panel Category", description="Location of add-on panel", default="Tool"
)
def draw(self, context):
draw_prefs(self, context, keymaps)
keymaps = []
classes = (
BLENDIR_OT_start,
BLENDIR_OT_new_structure,
BLENDIR_OT_edit_structure,
BLENDIR_OT_delete_structure,
BLENDIR_OT_import_structure,
BLENDIR_OT_directory_browser,
BLENDIR_OT_save_blend,
BLENDIR_OT_bookmarks,
BLENDIR_OT_open_bookmark,
BLENDIR_OT_edit_bookmarks,
BLENDIR_OT_change_page,
BLENDIR_OT_open_bookmarks_pie,
BLENDIR_OT_open_reference,
BLENDIR_OT_reset_props,
BLENDIR_OT_open_recent,
BLENDIR_OT_edit_recent,
BLENDIR_OT_render_animation,
BLENDIR_OT_render_image,
BLENDIR_OT_open_preferences,
BLENDIR_OT_save_panel_category,
BLENDIR_PT_main,
BLENDIR_MT_bookmarks_pie,
BLENDIR_MT_references_pie,
BLENDIR_MT_recent_pie,
BLENDIR_PG_properties,
BLENDIR_PG_bookmark,
BLENDIR_AP_preferences,
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.Scene.blendir_props = bpy.props.PointerProperty(
type=BLENDIR_PG_properties
)
bpy.types.Scene.blendir_bookmarks = bpy.props.CollectionProperty(
type=BLENDIR_PG_bookmark
)
# add keymaps
key_config = bpy.context.window_manager.keyconfigs.addon
if key_config:
keymap = key_config.keymaps.new("3D View", space_type="VIEW_3D")
keymap_item = keymap.keymap_items.new(
"blendir.start", type="F", value="PRESS", shift=True, ctrl=True
)
keymaps.append((keymap, keymap_item))
keymap_item = keymap.keymap_items.new(
"blendir.open_bookmarks_pie", type="F", value="PRESS", shift=True
)
keymaps.append((keymap, keymap_item))
id = "wm.call_menu_pie"
keymap_item = keymap.keymap_items.new(id, type="F", value="PRESS", ctrl=True)
keymap_item.properties.name = "BLENDIR_MT_references_pie"
keymaps.append((keymap, keymap_item))
keymap_item = keymap.keymap_items.new(
id, type="R", value="PRESS", shift=True, ctrl=True
)
keymap_item.properties.name = "BLENDIR_MT_recent_pie"
keymaps.append((keymap, keymap_item))
keymap_item = keymap.keymap_items.new(
"blendir.render_image", type="F12", value="PRESS", shift=True
)
keymaps.append((keymap, keymap_item))
keymap_item = keymap.keymap_items.new(
"blendir.render_animation", type="F12", value="PRESS", shift=True, ctrl=True
)
keymaps.append((keymap, keymap_item))
def unregister():
# remove keymaps
for keymap, keymap_item in keymaps:
keymap.keymap_items.remove(keymap_item)
keymaps.clear()
del bpy.types.Scene.blendir_bookmarks
del bpy.types.Scene.blendir_props
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
if __name__ == "__main__":
register()