From 365d82f1d5d9bb8890da60852efe08ce7354c1a6 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 9 Dec 2024 15:12:39 +0500 Subject: [PATCH] Loading texture maps - fallback to absolute paths If it's not possible to get relative path, fallback to absolute path and show an info message. --- src/bonsai/bonsai/bim/module/style/operator.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bonsai/bonsai/bim/module/style/operator.py b/src/bonsai/bonsai/bim/module/style/operator.py index fbbc388b66..a6fd66ae22 100644 --- a/src/bonsai/bonsai/bim/module/style/operator.py +++ b/src/bonsai/bonsai/bim/module/style/operator.py @@ -538,7 +538,12 @@ class ChooseTextureMapPath(bpy.types.Operator): abs_path = Path(self.filepath) if self.use_relative_path: - image_filepath = abs_path.relative_to(Path(tool.Ifc.get_path()).parent) + parent = Path(tool.Ifc.get_path()).parent + if abs_path.is_relative_to(parent): + image_filepath = abs_path.relative_to(parent) + else: + self.report({"INFO"}, "Path is not relative to the .ifc file, it will be saved as absolute.") + image_filepath = abs_path else: image_filepath = abs_path