From 5d9528d791defb1fb31243c3d730e432d7d3c865 Mon Sep 17 00:00:00 2001 From: Massimo Fabbro Date: Fri, 28 Feb 2025 16:19:10 +0100 Subject: [PATCH] Fix #6168. Now reload link button works It is fixed also an inconsistency problem when use relative path is True --- src/bonsai/bonsai/bim/module/project/operator.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/bonsai/bonsai/bim/module/project/operator.py b/src/bonsai/bonsai/bim/module/project/operator.py index 2b41699261..57262a7da5 100644 --- a/src/bonsai/bonsai/bim/module/project/operator.py +++ b/src/bonsai/bonsai/bim/module/project/operator.py @@ -1281,6 +1281,13 @@ class UnloadLink(bpy.types.Operator): # Let's assume that user might delete it. if empty_handle := link.empty_handle: bpy.data.objects.remove(empty_handle) + + #following lines removes the library also when use_relative_path=True, otherwise it doesn't + libraries = bpy.data.libraries + for library in libraries: + if library.name == self.filepath + ".cache.blend": + bpy.data.libraries.remove(library) + link.is_loaded = False if not any([l.is_loaded for l in links]): @@ -1442,6 +1449,12 @@ class ReloadLink(bpy.types.Operator): for library in get_linked_ifcs(): library.reload() + + is_abs = os.path.isabs(Path(self.filepath)) + use_relative_path = not is_abs + bpy.ops.bim.unlink_ifc(filepath = self.filepath) + status = bpy.ops.bim.link_ifc(filepath=self.filepath, use_cache=False, use_relative_path = use_relative_path) + return {"FINISHED"}