forked from MarcusZuber/kittenExport
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
115 lines (98 loc) · 3.04 KB
/
__init__.py
File metadata and controls
115 lines (98 loc) · 3.04 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
"""
KittenExport plugin for blender
Copyright (C) 2025 Marcus Zuber
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import bpy
# Import modules with all classes and functions
from . import utils
from .thruster import (
ThrusterProperties,
OBJECT_OT_add_thruster,
OBJECT_PT_thruster_panel
)
from .engine import (
EngineProperties,
OBJECT_OT_add_engine,
OBJECT_PT_engine_panel,
)
from .export import (
OBJECT_OT_export_ksa_metadata,
OBJECT_OT_export_glb_with_meta,
)
from .menu import (
VIEW3D_MT_ksa_add,
menu_func_add,
menu_func_export,
)
# Addon metadata
bl_info = {
"name": "Kitten export",
"blender": (4, 50, 0),
"category": ["Add Mesh", "Import-Export"],
}
# List of all classes to register
classes = (
ThrusterProperties,
EngineProperties,
OBJECT_OT_add_thruster,
OBJECT_OT_add_engine,
OBJECT_PT_thruster_panel,
OBJECT_PT_engine_panel,
OBJECT_OT_export_ksa_metadata,
OBJECT_OT_export_glb_with_meta,
VIEW3D_MT_ksa_add,
)
def register():
"""Register all addon classes and properties."""
# Register all classes
for cls in classes:
try:
bpy.utils.register_class(cls)
except Exception:
pass
# Register object properties
try:
bpy.types.Object.thruster_props = bpy.props.PointerProperty(type=ThrusterProperties)
bpy.types.Object.engine_props = bpy.props.PointerProperty(type=EngineProperties)
except Exception:
pass
# Register menu functions
try:
# Register the KSA menu in the main Add menu
bpy.types.VIEW3D_MT_add.append(menu_func_add)
# Register export in File > Export menu
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
except Exception:
pass
print("Kitten export addon registered")
def unregister():
"""Unregister all addon classes and properties."""
# Remove menu functions
try:
bpy.types.VIEW3D_MT_add.remove(menu_func_add)
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
except Exception:
pass
# Remove object properties
try:
del bpy.types.Object.thruster_props
del bpy.types.Object.engine_props
except Exception:
pass
# Unregister all classes in reverse order
for cls in reversed(classes):
try:
bpy.utils.unregister_class(cls)
except Exception:
pass
print("Kitten export addon unregistered")