forked from LuxCoreRender/BlendLuxCore
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path__init__.py
More file actions
83 lines (62 loc) · 2.17 KB
/
__init__.py
File metadata and controls
83 lines (62 loc) · 2.17 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
# Import standard modules
import platform
import os
import sys
import pathlib
from importlib.metadata import version
if platform.system() in {"Linux", "Darwin"}:
# Required for downloads from the LuxCore Online Library
import certifi
os.environ["SSL_CERT_FILE"] = certifi.where()
os.environ["REQUESTS_CA_BUNDLE"] = certifi.where()
# Support reloading
# https://developer.blender.org/docs/handbook/extensions/addon_dev_setup/#reloading-scripts
_needs_reload = "bpy" in locals()
# Import Blender packages
import bpy
import addon_utils
import nodeitems_utils
# Check if Blender and OS versions are compatible
if bpy.app.version < (4, 2, 0):
raise RuntimeError(
"\n\nUnsupported Blender version. "
"4.2 or higher is required by BlendLuxCore."
)
# Take care of PyLuxCore, as other modules may want to import it
from . import luxloader
if _needs_reload:
import importlib
luxloader = importlib.reload(luxloader)
luxloader.ensure_pyluxcore()
# Import pyluxcore
try:
import pyluxcore
except ImportError as error:
msg = f"\n\nCould not import pyluxcore. \n\nImportError: {error}"
# Raise from None to suppress the unhelpful
# "during handling of the above exception, ..."
raise RuntimeError(msg) from error
# Import other modules
from . import utils, properties, export, nodes, operators, engine, handlers, ui
if _needs_reload:
import importlib
utils = importlib.reload(utils)
properties = importlib.reload(properties)
export = importlib.reload(export)
nodes = importlib.reload(nodes)
operators = importlib.reload(operators)
handlers = importlib.reload(handlers)
engine = importlib.reload(engine)
ui = importlib.reload(ui)
# Handle registering and unregistering
# Warning: submodule order matters (for reloading, in particular)
submodules = (properties, nodes, operators, handlers, engine, ui)
def register():
utils.register_module("Main", [], submodules)
pyluxcore.Init(utils.log.LuxCoreLog.add)
print(
f"BlendLuxCore {utils.get_version_string()} registered "
f"(with pyluxcore {version('pyluxcore')})"
)
def unregister():
utils.unregister_module("Main", [], submodules)