-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path__init__.py
More file actions
336 lines (245 loc) · 9.11 KB
/
Copy path__init__.py
File metadata and controls
336 lines (245 loc) · 9.11 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# ----------------------------------------------------------
# File __init__.py
# ----------------------------------------------------------
# Addon info
# ##### BEGIN GPL LICENSE BLOCK #####
#
# 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 2
# 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, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
##############################################################################################
bl_info = {
"name": "BDENTAL", ###################Addon name
"author": "Essaid Issam Dakir DMD",
"version": (1, 0, 0),
"blender": (2, 90, 1), ################# Blender working version
"location": "3D View -> UI SIDE PANEL ",
"description": "3D Tools suite for Digital Dentistry", ########### Addon description
"warning": "",
"doc_url": "",
"tracker_url": "",
"category": "Dental", ################## Addon category
}
#############################################################################################
# IMPORTS :
#############################################################################################
# Python imports :
import sys, os, bpy
from importlib import import_module
from os.path import dirname, join, realpath, abspath, exists
sys.stdout.reconfigure(encoding="cp65001") # activate unicode characters in windows CLI
#############################################################
def ImportReq(REQ_DICT):
Pkgs = []
for mod, pkg in REQ_DICT.items():
try:
import_module(mod)
except ImportError:
Pkgs.append(pkg)
return Pkgs
###################################################
REQ_DICT = {
"SimpleITK": "SimpleITK==2.0.2",
"vtk": "vtk==9.0.1",
"cv2": "opencv-contrib-python==4.4.0.46",
}
ADDON_DIR = dirname(abspath(__file__))
REQ_DIR = join(ADDON_DIR, "Resources", "Requirements")
if not sys.path[0] == REQ_DIR :
sys.path.insert(0, REQ_DIR)
NotFoundPkgs = ImportReq(REQ_DICT)
if NotFoundPkgs :
############################
# Install Req Registration :
############################
from .Operators import BDENTAL_InstallReq
def register():
BDENTAL_InstallReq.register()
def unregister():
BDENTAL_InstallReq.unregister()
if __name__ == "__main__":
register()
else :
######################
# Addon Registration :
######################
# Addon modules imports :
from . import BDENTAL_Props, BDENTAL_Panel
from .Operators import BDENTAL_ScanOperators
addon_modules = [
BDENTAL_Props,
BDENTAL_Panel,
BDENTAL_ScanOperators,
]
init_classes = []
def register():
for module in addon_modules:
module.register()
for cl in init_classes:
bpy.utils.register_class(cl)
def unregister():
for cl in init_classes:
bpy.utils.unregister_class(cl)
for module in reversed(addon_modules):
module.unregister()
if __name__ == "__main__":
register()
# ADDON_DIR = dirname(abspath(__file__))
# REQ_DIR = join(ADDON_DIR, join(f"Resources{SS}Requirements"))
# REQ_ZIP = join(REQ_DIR, "BDENTAL_Req.zip")
# sys.path.insert(0, REQ_DIR)
# # if exists(REQ_ZIP):
# # from BDENTAL_rarfile import RarFile
# # with RarFile(REQ_RAR) as RarF:
# # RarF.extract(RarF.namelist()[0])
# # print("Requirements Un-Compressed!")
# if exists(REQ_ZIP):
# with zipfile.ZipFile(REQ_ZIP, "r") as Zip_File:
# Zip_File.extractall(REQ_DIR)
# os.remove(REQ_ZIP)
# print("Requirements Un-Compressed!")
# #############################################################
# # Addon modules imports :
# from . import BDENTAL_Props, BDENTAL_Panel
# from .Operators import BDENTAL_ScanOperators
# ############################################################################################
# # Registration :
# ############################################################################################
# addon_modules = [
# BDENTAL_Props,
# BDENTAL_Panel,
# BDENTAL_ScanOperators,
# ]
# init_classes = []
# def register():
# for module in addon_modules:
# module.register()
# for cl in init_classes:
# bpy.utils.register_class(cl)
# def unregister():
# for cl in init_classes:
# bpy.utils.unregister_class(cl)
# for module in reversed(addon_modules):
# module.unregister()
# if __name__ == "__main__":
# register()
# Requirements = {
# "SimpleITK": "SimpleITK==2.0.2",
# "vtk": "vtk==9.0.1",
# "cv2.aruco": "opencv-contrib-python==4.4.0.46", # working version4.4.0.46 # Uptodate 01082021: 4.5.1.48
# }
# def isConnected():
# try:
# sock = socket.create_connection(("www.google.com", 80))
# if sock is not None:
# print("Clossing socket")
# sock.close
# return True
# except OSError:
# pass
# return False
# def BlenderRequirementsPipInstall(path, modules):
# # Download and install requirement if not AddonPacked version:
# if sys.platform == "win32":
# Blender_python_path = sys.executable
# if sys.platform == "darwin":
# Blender_python_path = join(sys.base_exec_prefix, f"bin{SS}python3.7m")
# subprocess.call(
# f"{Blender_python_path} -m ensurepip ",
# shell=True,
# )
# subprocess.call(
# f"{Blender_python_path} -m pip install -U pip ",
# shell=True,
# )
# print("Blender pip upgraded")
# for module in modules:
# command = f'{Blender_python_path} -m pip install {module} --target "{path}"'
# subprocess.call(command, shell=True)
# print(f"{module}Downloaded and installed")
# ##########################
# print("requirements installed successfuly.")
# ##########################################################################
# ##########################################################################
# NotFoundPkgs = []
# for mod, pkg in Requirements.items():
# try:
# import_module(mod)
# except ImportError:
# NotFoundPkgs.append(pkg)
# if NotFoundPkgs == []:
# print("Requirement already installed")
# # Addon modules imports :
# from . import BDENTAL_Props, BDENTAL_Panel
# from .Operators import BDENTAL_ScanOperators
# ############################################################################################
# # Registration :
# ############################################################################################
# addon_modules = [
# BDENTAL_Props,
# BDENTAL_Panel,
# BDENTAL_ScanOperators,
# ]
# init_classes = []
# def register():
# for module in addon_modules:
# module.register()
# for cl in init_classes:
# bpy.utils.register_class(cl)
# def unregister():
# for cl in init_classes:
# bpy.utils.unregister_class(cl)
# for module in reversed(addon_modules):
# module.unregister()
# if __name__ == "__main__":
# register()
# else:
# for pkg in NotFoundPkgs:
# print(f"{pkg} : not installed")
# ######################################################################################
# if isConnected():
# BlenderRequirementsPipInstall(path=REQ_DIR, modules=NotFoundPkgs)
# # Addon modules imports :
# from . import BDENTAL_Props, BDENTAL_Panel
# from .Operators import BDENTAL_ScanOperators
# addon_modules = [
# BDENTAL_Props,
# BDENTAL_Panel,
# BDENTAL_ScanOperators,
# ]
# init_classes = []
# ############################################################################################
# # Registration :
# ############################################################################################
# def register():
# for module in addon_modules:
# module.register()
# for cl in init_classes:
# bpy.utils.register_class(cl)
# def unregister():
# for cl in init_classes:
# bpy.utils.unregister_class(cl)
# for module in reversed(addon_modules):
# module.unregister()
# if __name__ == "__main__":
# register()
# else:
# def register():
# message = "Please Check Internet Connexion and restart Blender! "
# print(message)
# def unregister():
# pass
# if __name__ == "__main__":
# register()