mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 03:21:00 +00:00
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:
@@ -112,6 +112,7 @@ class IfcStore:
|
|||||||
if IfcStore.path:
|
if IfcStore.path:
|
||||||
try:
|
try:
|
||||||
IfcStore.load_file(IfcStore.path)
|
IfcStore.load_file(IfcStore.path)
|
||||||
|
tool.Ifc.after_file_loaded()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to load file {IfcStore.path}. Error details: {e}")
|
print(f"Failed to load file {IfcStore.path}. Error details: {e}")
|
||||||
return IfcStore.file
|
return IfcStore.file
|
||||||
@@ -201,6 +202,7 @@ class IfcStore:
|
|||||||
IfcStore.file = ifcopenshell.open(path, should_stream=True)
|
IfcStore.file = ifcopenshell.open(path, should_stream=True)
|
||||||
else:
|
else:
|
||||||
IfcStore.file = ifcopenshell.open(path)
|
IfcStore.file = ifcopenshell.open(path)
|
||||||
|
tool.Ifc.after_file_loaded()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_schema() -> ifcopenshell.ifcopenshell_wrapper.schema_definition:
|
def get_schema() -> ifcopenshell.ifcopenshell_wrapper.schema_definition:
|
||||||
|
|||||||
@@ -154,7 +154,6 @@ class CreateProject(bpy.types.Operator):
|
|||||||
core.create_project(
|
core.create_project(
|
||||||
tool.Ifc, tool.Georeference, tool.Project, tool.Spatial, schema=props.export_schema, template=template
|
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()
|
tool.Blender.register_toolbar()
|
||||||
|
|
||||||
def rollback(self, data):
|
def rollback(self, data):
|
||||||
@@ -1072,7 +1071,6 @@ class LoadProjectElements(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.props = tool.Project.get_project_props()
|
self.props = tool.Project.get_project_props()
|
||||||
self.file = tool.Ifc.get()
|
self.file = tool.Ifc.get()
|
||||||
bonsai.bim.schema.reload(self.file.schema_identifier)
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
logger = logging.getLogger("ImportIFC")
|
logger = logging.getLogger("ImportIFC")
|
||||||
path_log = tool.Blender.get_data_dir_path("process.log")
|
path_log = tool.Blender.get_data_dir_path("process.log")
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import ifcopenshell.util.element
|
|||||||
import ifcopenshell.util.schema
|
import ifcopenshell.util.schema
|
||||||
import bonsai.core.tool
|
import bonsai.core.tool
|
||||||
import bonsai.bim.handler
|
import bonsai.bim.handler
|
||||||
|
import bonsai.bim.schema
|
||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from bonsai.bim.ifc import IfcStore, IFC_CONNECTED_TYPE
|
from bonsai.bim.ifc import IfcStore, IFC_CONNECTED_TYPE
|
||||||
@@ -61,11 +62,17 @@ class Ifc(bonsai.core.tool.Ifc):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def set(cls, ifc: ifcopenshell.file) -> None:
|
def set(cls, ifc: ifcopenshell.file) -> None:
|
||||||
IfcStore.file = ifc
|
IfcStore.file = ifc
|
||||||
|
cls.after_file_loaded()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get(cls) -> ifcopenshell.file:
|
def get(cls) -> ifcopenshell.file:
|
||||||
return IfcStore.get_file()
|
return IfcStore.get_file()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def after_file_loaded(cls) -> None:
|
||||||
|
assert IfcStore.file
|
||||||
|
bonsai.bim.schema.reload(IfcStore.file.schema_identifier)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_path(cls, value: str) -> None:
|
def set_path(cls, value: str) -> None:
|
||||||
bim_props = tool.Blender.get_bim_props()
|
bim_props = tool.Blender.get_bim_props()
|
||||||
|
|||||||
Reference in New Issue
Block a user