-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
71 lines (63 loc) · 2.25 KB
/
__init__.py
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
from . import handlers
from . import panels
from . import operators
from . import properties
import bpy
bl_info = {
"name": "Bone Generator",
"author": "Florian Vazelle",
"version": (0, 1, 0),
"blender": (2, 91, 0),
"location": "Properties > Scene",
"description": "Bones generation for a 3D mesh with the principal component analysis method",
"warning": "",
"wiki_url": "",
"tracker_url": "https://github.com/florianvazelle/bone-generator/issues",
"support": "TESTING",
"category": "Rigging",
}
# -------------------------------------------------------------------
# This section is dedicated to make the "Reload Scripts" operator of
# Blender truly work to be able to update the add-on while developping.
# This feature only reloads this __init__ file, so we force reloading all
# other files here.
# When loaded is already in local, we know this is called by "Reload plugins"
if locals().get('loaded') or True:
loaded = False
from importlib import reload
from sys import modules
import os
for i in range(3): # Try up to three times, in case of ordering errors
err = False
modules[__name__] = reload(modules[__name__])
submodules = list(modules.items())
for name, module in submodules:
if name.startswith(f"{__package__}."):
if module.__file__ is None:
# This is a namespace, no need to do anything
continue
elif not os.path.isfile(module.__file__):
# File has been removed
del modules[name]
del globals()[name]
else:
print(f"Reloading: {module}")
try:
globals()[name] = reload(module)
except Exception as e:
print(e)
err = True
if not err:
break
#del reload, modules
# -------------------------------------------------------------------
def register():
properties.register()
operators.register()
panels.register()
handlers.register()
def unregister():
properties.unregister()
operators.unregister()
panels.unregister()
handlers.unregister()