From a656d32e566bb046241e93f5273c27d2f34fa1ff Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 20 Mar 2024 11:43:22 +0500 Subject: [PATCH] fix issue with removing collections and scenes unlinking .ifc it couldn't find linked collections and scenes since it was comparing `filepath` from `props.links` (.ifc file) and collection.library.filepath (which is .blend file) --- .../blenderbim/bim/module/project/operator.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/project/operator.py b/src/blenderbim/blenderbim/bim/module/project/operator.py index ba58808752..8da0835e14 100644 --- a/src/blenderbim/blenderbim/bim/module/project/operator.py +++ b/src/blenderbim/blenderbim/bim/module/project/operator.py @@ -894,13 +894,19 @@ class UnloadLink(bpy.types.Operator): self.filepath = self.filepath.replace("\\", "/") filepath = self.filepath if not os.path.isabs(filepath): - filepath = os.path.abspath(os.path.join(bpy.path.abspath("//"), filepath)).replace("\\", "/") + filepath = os.path.abspath(os.path.join(bpy.path.abspath("//"), filepath)) + filepath = Path(filepath) + if filepath.suffix.lower() == ".ifc": + filepath = filepath.with_suffix(".ifc.cache.blend") + for collection in context.scene.collection.children: - if collection.library and collection.library.filepath.replace("\\", "/") == filepath: + if collection.library and Path(collection.library.filepath) == filepath: context.scene.collection.children.unlink(collection) + for scene in bpy.data.scenes: - if scene.library and scene.library.filepath.replace("\\", "/") == filepath: + if scene.library and Path(scene.library.filepath) == filepath: bpy.data.scenes.remove(scene) + link = context.scene.BIMProjectProperties.links.get(self.filepath) link.is_loaded = False return {"FINISHED"}