-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproperties.py
More file actions
79 lines (61 loc) · 2.52 KB
/
properties.py
File metadata and controls
79 lines (61 loc) · 2.52 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
import bpy
from bpy.types import PropertyGroup
from bpy.props import PointerProperty, StringProperty, IntProperty, CollectionProperty, EnumProperty, BoolProperty
from bpy.utils import register_class, unregister_class
from . import constants
# Module-level list to track registered classes for clean unregister
_classes = []
class PawlygonMissingItem(PropertyGroup):
"""Property group for storing a single missing shapekey name in the UI list."""
name: StringProperty()
def get_list_items(self, context):
"""
Callback function to generate enum items from available shapekey lists.
Used by the EnumProperty to populate the dropdown with list names from constants.
Returns:
List of (identifier, name, description) tuples for EnumProperty
"""
return [
(name, name, f"Check against {name} list")
for name in constants.SHAPEKEY_LISTS.keys()
]
def on_target_changed(self, context):
"""Clear missing shapekey list whenever the target object changes."""
self.pawlygon_missing_list.clear()
self.pawlygon_missing_count = 0
self.pawlygon_all_present = False
def register():
# Register property group class first
global _classes
_classes = [PawlygonMissingItem]
for cls in _classes:
register_class(cls)
# Scene properties for missing shapekey workflow
bpy.types.Scene.pawlygon_target_object = PointerProperty(
type=bpy.types.Object,
name="Target Object",
description="Object to check for missing shapekeys",
update=on_target_changed
)
bpy.types.Scene.pawlygon_list_name = EnumProperty(
name="Shapekey List",
description="Select which shapekey list to check against",
items=get_list_items
)
# Properties for tracking missing shapekey state
bpy.types.Scene.pawlygon_missing_count = IntProperty(default=0)
bpy.types.Scene.pawlygon_missing_list = CollectionProperty(type=PawlygonMissingItem)
bpy.types.Scene.pawlygon_missing_index = IntProperty(default=0)
bpy.types.Scene.pawlygon_all_present = BoolProperty(default=False)
def unregister():
# Remove scene properties first, then unregister classes
del bpy.types.Scene.pawlygon_target_object
del bpy.types.Scene.pawlygon_list_name
del bpy.types.Scene.pawlygon_missing_count
del bpy.types.Scene.pawlygon_missing_list
del bpy.types.Scene.pawlygon_missing_index
del bpy.types.Scene.pawlygon_all_present
global _classes
for cls in reversed(_classes):
unregister_class(cls)
_classes = []