From c9eea76e57c85a5b2fd70fb1c58edb3b4fbd5bd8 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 21 May 2025 14:46:50 +0500 Subject: [PATCH] bim.execute_ifc_clash - more user-friendly error when one of the filepaths do not exist --- src/bonsai/bonsai/bim/module/clash/operator.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/bonsai/bonsai/bim/module/clash/operator.py b/src/bonsai/bonsai/bim/module/clash/operator.py index 4d8d9f43a6..a7b26df3da 100644 --- a/src/bonsai/bonsai/bim/module/clash/operator.py +++ b/src/bonsai/bonsai/bim/module/clash/operator.py @@ -24,6 +24,7 @@ import logging import numpy as np import ifcopenshell import bonsai.tool as tool +from pathlib import Path from bpy_extras.io_utils import ExportHelper, ImportHelper from math import radians from mathutils import Matrix, Vector @@ -226,6 +227,16 @@ class ExecuteIfcClash(bpy.types.Operator, ExportHelper): self.props = tool.Clash.get_clash_props() + for clash_set in self.props.clash_sets: + for clash_sources in clash_set.get_clash_sources().values(): + for clash_source in clash_sources: + if not Path(clash_source.name).is_file(): + self.report( + {"ERROR"}, + f"One of the provided clash source filepaths do not exist: '{clash_source.name}'.", + ) + return {"CANCELLED"} + _, extension = os.path.splitext(self.filepath) if extension != ".bcf": self.filepath = bpy.path.ensure_ext(self.filepath, ".json")