Fix missing pset templates update when changing IFC filepath #6979

E.g. when user opened .blend file and ifc filepath was pointing to a wrong destination, after they changed the filepath pset templates wouldn't reload.
This commit is contained in:
Andrej730
2025-08-06 14:43:52 +05:00
parent 2154200697
commit 6757026e3e
3 changed files with 9 additions and 2 deletions
+2
View File
@@ -112,6 +112,7 @@ class IfcStore:
if IfcStore.path:
try:
IfcStore.load_file(IfcStore.path)
tool.Ifc.after_file_loaded()
except Exception as e:
print(f"Failed to load file {IfcStore.path}. Error details: {e}")
return IfcStore.file
@@ -201,6 +202,7 @@ class IfcStore:
IfcStore.file = ifcopenshell.open(path, should_stream=True)
else:
IfcStore.file = ifcopenshell.open(path)
tool.Ifc.after_file_loaded()
@staticmethod
def get_schema() -> ifcopenshell.ifcopenshell_wrapper.schema_definition:
@@ -154,7 +154,6 @@ class CreateProject(bpy.types.Operator):
core.create_project(
tool.Ifc, tool.Georeference, tool.Project, tool.Spatial, schema=props.export_schema, template=template
)
bonsai.bim.schema.reload(tool.Ifc.get().schema_identifier)
tool.Blender.register_toolbar()
def rollback(self, data):
@@ -1072,7 +1071,6 @@ class LoadProjectElements(bpy.types.Operator):
def execute(self, context):
self.props = tool.Project.get_project_props()
self.file = tool.Ifc.get()
bonsai.bim.schema.reload(self.file.schema_identifier)
start = time.time()
logger = logging.getLogger("ImportIFC")
path_log = tool.Blender.get_data_dir_path("process.log")
+7
View File
@@ -26,6 +26,7 @@ import ifcopenshell.util.element
import ifcopenshell.util.schema
import bonsai.core.tool
import bonsai.bim.handler
import bonsai.bim.schema
import bonsai.tool as tool
from pathlib import Path
from bonsai.bim.ifc import IfcStore, IFC_CONNECTED_TYPE
@@ -61,11 +62,17 @@ class Ifc(bonsai.core.tool.Ifc):
@classmethod
def set(cls, ifc: ifcopenshell.file) -> None:
IfcStore.file = ifc
cls.after_file_loaded()
@classmethod
def get(cls) -> ifcopenshell.file:
return IfcStore.get_file()
@classmethod
def after_file_loaded(cls) -> None:
assert IfcStore.file
bonsai.bim.schema.reload(IfcStore.file.schema_identifier)
@classmethod
def set_path(cls, value: str) -> None:
bim_props = tool.Blender.get_bim_props()