-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpointerproperty-binding.py
More file actions
30 lines (21 loc) · 884 Bytes
/
Copy pathpointerproperty-binding.py
File metadata and controls
30 lines (21 loc) · 884 Bytes
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
# Bind a PropertyGroup to an ID type via PointerProperty so its data
# survives save/load. Plain Python attributes set on bpy.types.Object
# do not persist across .blend reload.
#
# Unregister deletes the binding BEFORE unregister_class invalidates
# the PropertyGroup type.
#
# Reference:
# https://docs.blender.org/api/current/bpy.props.html#bpy.props.PointerProperty
import bpy
class EXAMPLE_PG_object_data(bpy.types.PropertyGroup):
label: bpy.props.StringProperty(name="Label", default="")
score: bpy.props.FloatProperty(name="Score", default=0.0)
def register():
bpy.utils.register_class(EXAMPLE_PG_object_data)
bpy.types.Object.example_data = bpy.props.PointerProperty(type=EXAMPLE_PG_object_data)
def unregister():
del bpy.types.Object.example_data
bpy.utils.unregister_class(EXAMPLE_PG_object_data)
if __name__ == "__main__":
register()