From c4dbbe85fcb9a35c86edf0fd021203b81f155e5c Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 27 Jan 2025 20:41:26 +1100 Subject: [PATCH] Fix bug where library wasn't actually removed when unlinking an IFC. Previously the collection and scene object was removed, but this is obviously not sufficient since the bpy.data.library still exists (which meant that if you relinked it, regardless of your cache setting, it'd just load the existing Blender file which is completely useless). --- src/bonsai/bonsai/bim/module/project/operator.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/project/operator.py b/src/bonsai/bonsai/bim/module/project/operator.py index 8afa3c77cc..54fe5b1a2c 100644 --- a/src/bonsai/bonsai/bim/module/project/operator.py +++ b/src/bonsai/bonsai/bim/module/project/operator.py @@ -1030,7 +1030,7 @@ class LinkIfc(bpy.types.Operator): class UnlinkIfc(bpy.types.Operator): bl_idname = "bim.unlink_ifc" - bl_label = "UnLink IFC" + bl_label = "Unlink IFC" bl_options = {"REGISTER", "UNDO"} bl_description = "Remove the selected file from the link list" filepath: bpy.props.StringProperty() @@ -1056,13 +1056,9 @@ class UnloadLink(bpy.types.Operator): if filepath.suffix.lower() == ".ifc": filepath = filepath.with_suffix(".ifc.cache.blend") - for collection in context.scene.collection.children[:]: - if collection.library and Path(collection.library.filepath) == filepath: - bpy.data.collections.remove(collection) - - for scene in bpy.data.scenes[:]: - if scene.library and Path(scene.library.filepath) == filepath: - bpy.data.scenes.remove(scene) + for library in list(bpy.data.libraries): + if tool.Blender.ensure_blender_path_is_abs(Path(library.filepath)) == filepath: + bpy.data.libraries.remove(library) links = context.scene.BIMProjectProperties.links link = links.get(self.filepath)