From f9bf8897bc2c46049aced223f344e0d8612bd9ed Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 22 Apr 2025 16:36:58 +0500 Subject: [PATCH] Fix error linking ifc files with relative filepaths going upwards Mentioned in https://github.com/IfcOpenShell/IfcOpenShell/pull/6540#issuecomment-2820938852 --- src/bonsai/bonsai/bim/module/project/operator.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/project/operator.py b/src/bonsai/bonsai/bim/module/project/operator.py index 7e12477c6c..685cfd34c1 100644 --- a/src/bonsai/bonsai/bim/module/project/operator.py +++ b/src/bonsai/bonsai/bim/module/project/operator.py @@ -1320,11 +1320,13 @@ class LoadLink(bpy.types.Operator): return {"FINISHED"} def link_blend(self, filepath: Path) -> None: - with bpy.data.libraries.load(str(filepath), link=True) as (data_from, data_to): + # Resolve it, otherwise it might not match with `library.filepath`. + blend_filepath = filepath.resolve() + with bpy.data.libraries.load(str(blend_filepath), link=True) as (data_from, data_to): data_to.scenes = data_from.scenes link = tool.Project.get_project_props().links[self.filepath] for scene in bpy.data.scenes: - if not scene.library or Path(scene.library.filepath) != filepath: + if not scene.library or Path(scene.library.filepath) != blend_filepath: continue for child in scene.collection.children: if "IfcProject" not in child.name: