Fix error linking ifc files with relative filepaths going upwards

Mentioned in https://github.com/IfcOpenShell/IfcOpenShell/pull/6540#issuecomment-2820938852
This commit is contained in:
Andrej730
2025-04-22 16:36:58 +05:00
parent 932939099a
commit f9bf8897bc
@@ -1320,11 +1320,13 @@ class LoadLink(bpy.types.Operator):
return {"FINISHED"} return {"FINISHED"}
def link_blend(self, filepath: Path) -> None: 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 data_to.scenes = data_from.scenes
link = tool.Project.get_project_props().links[self.filepath] link = tool.Project.get_project_props().links[self.filepath]
for scene in bpy.data.scenes: 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 continue
for child in scene.collection.children: for child in scene.collection.children:
if "IfcProject" not in child.name: if "IfcProject" not in child.name: