forked from taichi-dev/taichi_blend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taichi-Blend-Dev.py
78 lines (60 loc) · 1.85 KB
/
Taichi-Blend-Dev.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
72
73
74
75
76
77
78
import sys
import imp
import os
bl_info = {
'name': 'Taichi Blend (dev mode)',
'description': 'Taichi Blender intergration',
'author': 'archibate <1931127624@qq.com>',
'version': (0, 0, 0),
'blender': (2, 81, 0),
'location': 'Scripting module',
'support': 'TESTING',
'wiki_url': 'https://github.com/taichi-dev/taichi_blend/wiki',
'tracker_url': 'https://github.com/taichi-dev/taichi_blend/issues',
'warning': 'Development mode',
'category': 'Physics',
}
repo_path = '/home/bate/Develop/blender_taichi'
sys.path.insert(0, repo_path)
sys.path.insert(0, os.path.join(repo_path, 'external/ptina'))
registered = False
def register():
print('Taichi-Blend-Dev register...')
import taichi_blend
taichi_blend.register()
global registered
registered = True
print('...register done')
def unregister():
print('Taichi-Blend-Dev unregister...')
import taichi_blend
taichi_blend.unregister()
global registered
registered = False
print('...unregister done')
def reload_addon():
if registered:
import taichi_blend
taichi_blend.unregister()
del taichi_blend
mods_to_del = []
for k, v in sys.modules.items():
if hasattr(v, '__file__') and v.__file__ is not None:
if v.__file__.startswith(repo_path):
print('reloading', k)
mods_to_del.append(k)
for k in mods_to_del:
sys.modules.pop(k)
import taichi_blend
taichi_blend.register()
@eval('lambda x: x()')
def _():
class Reload:
def __repr__(self):
import os
import bpy
os.system('clear')
reload_addon()
bpy.context.scene.frame_current = bpy.context.scene.frame_current
return 'reloaded'
__import__('bpy').a = Reload()