-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreferences.py
More file actions
executable file
·91 lines (76 loc) · 2.08 KB
/
preferences.py
File metadata and controls
executable file
·91 lines (76 loc) · 2.08 KB
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
# type: ignore
from bpy.types import AddonPreferences, PropertyGroup, Context
from bpy.props import (
CollectionProperty,
StringProperty,
IntProperty,
FloatProperty,
BoolProperty,
FloatVectorProperty
)
class CustomProperties(PropertyGroup):
string_prop: StringProperty(
name="String",
default="",
)
int_prop: IntProperty(
name="Integer",
default=0,
)
class Preferences(AddonPreferences):
bl_idname = __package__
string_pref: StringProperty(
name="String",
default="",
)
int_pref: IntProperty(
name="Integer",
default=0,
)
float_pref: FloatProperty(
name="Float",
default=0.0,
)
bool_pref: BoolProperty(
name="Boolean",
default=False,
)
color_pref: FloatVectorProperty(
name="Color",
subtype="COLOR",
size=4,
min=0.0,
max=1.0,
default=(0.7, 0.7, 0.7, 1.0),
)
coordinate_pref: FloatVectorProperty(
name="Coordinate",
subtype="COORDINATES",
size=3,
default=(0.0, 0.0, 0.0),
)
name_number_sets: CollectionProperty(
type=CustomProperties
)
def draw(self, _: Context):
layout = self.layout
layout.label(text="This is an example of how to save and load settings in Blender.")
layout.prop(self, "string_pref")
layout.prop(self, "int_pref")
layout.prop(self, "float_pref")
layout.prop(self, "bool_pref")
layout.prop(self, "color_pref")
layout.prop(self, "coordinate_pref")
layout.operator("wm.add_menu_item")
if not self.name_number_sets:
layout.label(text="No items")
else:
for (index, item) in enumerate(self.name_number_sets):
r = layout.row()
r.prop(item, "string_prop")
r.prop(item, "int_prop")
r.operator("wm.remove_menu_item", text="Remove").index = index
def save(self):
print("Saved")
def load(self):
print("Loaded")