mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-20 12:12:15 +00:00
More reliable way to get bbim package name #5214
See #5214 for details, can't rely on 'bpy.context.preferences.addons' as it may contain a missing addons too (if addon was manually uninstalled and it won't be able to load but it will still appear in 'addons').
This commit is contained in:
@@ -59,6 +59,7 @@ last_error = None
|
||||
last_actions: deque = deque(maxlen=10)
|
||||
FIRST_INSTALLED_BBIM_VERSION: Union[str, None] = None
|
||||
REINSTALLED_BBIM_VERSION: Union[str, None] = None
|
||||
REGISTERED_BBIM_PACKAGE: str
|
||||
|
||||
|
||||
def initialize_bbim_semver():
|
||||
@@ -238,6 +239,10 @@ if IN_BLENDER:
|
||||
if platform.system() == "Windows":
|
||||
clean_up_dlls_safe_links()
|
||||
|
||||
import bonsai
|
||||
|
||||
bonsai.REGISTERED_BBIM_PACKAGE = __package__
|
||||
|
||||
import bonsai.bim
|
||||
|
||||
current_version = bbim_semver["version"]
|
||||
|
||||
@@ -1114,10 +1114,7 @@ class Blender(bonsai.core.tool.Blender):
|
||||
|
||||
@classmethod
|
||||
def get_blender_addon_package_name(cls) -> str:
|
||||
for package_name in bpy.context.preferences.addons.keys():
|
||||
if package_name.endswith(".bonsai"):
|
||||
return package_name
|
||||
return "bonsai"
|
||||
return bonsai.REGISTERED_BBIM_PACKAGE
|
||||
|
||||
@classmethod
|
||||
def get_bbim_extension_package(cls) -> types.ModuleType:
|
||||
@@ -1151,6 +1148,10 @@ class Blender(bonsai.core.tool.Blender):
|
||||
|
||||
for package_name in bpy.context.preferences.addons.keys():
|
||||
if package_name.endswith(".sun_position"):
|
||||
sun_position = importlib.import_module(package_name)
|
||||
try:
|
||||
sun_position = importlib.import_module(package_name)
|
||||
return sun_position
|
||||
except ModuleNotFoundError:
|
||||
pass
|
||||
|
||||
return sun_position
|
||||
|
||||
Reference in New Issue
Block a user