-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
78 lines (63 loc) · 2.21 KB
/
Copy path__init__.py
File metadata and controls
78 lines (63 loc) · 2.21 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
import bpy
import importlib
module_names = (
'rig_manager',
'rig_json_maker',
'renderer',
'ui',
)
##############################################################################
# Add-On Handling
##############################################################################
def register_properties():
from bpy.props import StringProperty, EnumProperty, IntProperty
# register properties only if they don't already exist
if not hasattr(bpy.types.Scene, 'colmap_rig_image_format'):
bpy.types.Scene.colmap_rig_image_format = EnumProperty(
name='Image Format',
description='Image file format for rendered frames',
items=(
('JPEG', 'JPEG', 'JPEG format'),
('PNG', 'PNG', 'PNG format'),
),
default='JPEG',
)
def unregister_properties():
for name in (
'colmap_rig_image_format',
):
if hasattr(bpy.types.Scene, name):
delattr(bpy.types.Scene, name)
# This list will be filled with the actual module objects at registration
__modules = []
def register():
# Clear the list on a re-register (e.g., F8)
__modules.clear()
# register scene properties first
register_properties()
for name in module_names:
try:
# Dynamically import the module.
# The f'.{name}' and __package__ are crucial for relative imports
module = importlib.import_module(f'.{name}', __package__)
module.register()
__modules.append(module)
print(f'Registered module: {name}')
except ImportError:
print(f'Error: Could not import module {name}')
except Exception as e:
print(f'Error registering module {name}: {e}')
def unregister():
# Unregister in the reverse order to avoid dependency issues
for module in reversed(__modules):
try:
module.unregister()
print(f'Unregistered module: {module.__name__}')
except Exception as e:
print(f'Error unregistering module {module.__name__}: {e}')
# Clear the list
__modules.clear()
# remove scene properties
unregister_properties()
if __name__ == '__main__':
register()