-
Notifications
You must be signed in to change notification settings - Fork 0
/
presets.py
61 lines (48 loc) · 1.78 KB
/
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
from bpy.types import Operator, Menu, Panel, PropertyGroup
from bpy.props import IntProperty, StringProperty
from bl_operators.presets import AddPresetBase
from bl_ui.utils import PresetPanel
class BLENDERPROJECTMANAGER_OT_add_preset(AddPresetBase, Operator):
bl_idname = "bpm.add_preset"
bl_label = "Add Preset"
preset_menu = "BlenderProjectManager_MT_SubDir_Presets"
preset_subdir = "project_presets"
preset_defines = [
"bpm = bpy.context.scene.bpm"
]
preset_values = [
"bpm.subdirs"
]
class BLENDERPROJECTMANAGER_OT_add_subdir(Operator):
bl_label = "Add Subdirectory"
bl_idname = "preferences.add_bpm_subdir"
def execute(self, context):
context.scene.bpm.subdirs.add()
return {"FINISHED"}
class BLENDERPROJECTMANAGER_OT_remove_subdir(Operator):
bl_label = "Add Subdirectory"
bl_idname = "preferences.remove_bpm_subdir"
index: IntProperty(default=0)
def execute(self, context):
context.scene.bpm.subdirs.remove(self.index)
return {"FINISHED"}
class BLENDERPROJECTMANAGER_PT_presets(PresetPanel, Panel):
bl_label = "Presets"
preset_subdir = "project_presets"
preset_operator = "script.execute_preset"
preset_add_operator = "bpm.add_preset"
class BLENDERPROJECTMANAGER_MT_subdir_presets(Menu):
bl_label = ""
preset_subdir = "project_presets"
preset_operator = "script.execute_preset"
draw = Menu.draw_preset
class BLENDERPROJECTMANAGER_subdir(PropertyGroup):
name: StringProperty(name="", default="custom")
classes = [
BLENDERPROJECTMANAGER_subdir,
BLENDERPROJECTMANAGER_OT_add_subdir,
BLENDERPROJECTMANAGER_OT_remove_subdir,
BLENDERPROJECTMANAGER_MT_subdir_presets,
BLENDERPROJECTMANAGER_OT_add_preset,
BLENDERPROJECTMANAGER_PT_presets
]