From c53885f642746c7b6352441eaed01479abd0f9f4 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 31 Oct 2024 14:38:25 +0500 Subject: [PATCH] bonsai ifcclash - add separate property for export path Example - https://i.imgur.com/bCRHx9q.png Needed so it will be easier to rerun ifc clash without providing the same filepath each time. --- src/bonsai/bonsai/bim/module/clash/operator.py | 13 +++++-------- src/bonsai/bonsai/bim/module/clash/prop.py | 5 +++++ src/bonsai/bonsai/bim/module/clash/ui.py | 6 +++++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/clash/operator.py b/src/bonsai/bonsai/bim/module/clash/operator.py index e199a3caa4..c51e27b423 100644 --- a/src/bonsai/bonsai/bim/module/clash/operator.py +++ b/src/bonsai/bonsai/bim/module/clash/operator.py @@ -205,16 +205,12 @@ class ExecuteIfcClash(bpy.types.Operator): bl_label = "Execute IFC Clash" bl_description = "Execute clash detection and save the information to a .bcf or .json file" filter_glob: bpy.props.StringProperty(default="*.bcf;*.json", options={"HIDDEN"}) - filepath: bpy.props.StringProperty(subtype="FILE_PATH") + filepath: bpy.props.StringProperty(subtype="FILE_PATH", options={"SKIP_SAVE"}) def invoke(self, context, event): - _, extension = os.path.splitext(self.filepath) - if extension != ".bcf": - self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".json") - if extension != ".json": - self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".bcf") - WindowManager = context.window_manager - WindowManager.fileselect_add(self) + if self.filepath: + return self.execute(context) + context.window_manager.fileselect_add(self) return {"RUNNING_MODAL"} def execute(self, context): @@ -229,6 +225,7 @@ class ExecuteIfcClash(bpy.types.Operator): if extension != ".json": self.filepath = bpy.path.ensure_ext(self.filepath, ".bcf") + self.props.export_path = self.filepath settings = ifcclash.ClashSettings() settings.output = self.filepath settings.logger = logging.getLogger("Clash") diff --git a/src/bonsai/bonsai/bim/module/clash/prop.py b/src/bonsai/bonsai/bim/module/clash/prop.py index e9337f1810..b112964fe4 100644 --- a/src/bonsai/bonsai/bim/module/clash/prop.py +++ b/src/bonsai/bonsai/bim/module/clash/prop.py @@ -101,6 +101,11 @@ class BIMClashProperties(PropertyGroup): p1: FloatVectorProperty(name="P1", default=(0.0, 0.0, 0.0), subtype="XYZ") p2: FloatVectorProperty(name="P2", default=(0.0, 0.0, 0.0), subtype="XYZ") active_clash_text: StringProperty(name="Active Clash Text") + export_path: StringProperty( + name="Export Path", + description=".bcf or .json file to export the clash results to", + subtype="FILE_PATH", + ) @property def active_clash_set(self): diff --git a/src/bonsai/bonsai/bim/module/clash/ui.py b/src/bonsai/bonsai/bim/module/clash/ui.py index 5c969da837..2a95b54ab3 100644 --- a/src/bonsai/bonsai/bim/module/clash/ui.py +++ b/src/bonsai/bonsai/bim/module/clash/ui.py @@ -118,8 +118,12 @@ class BIM_PT_ifcclash(Panel): row = layout.row() row.prop(props, "should_create_clash_snapshots") + + layout.prop(props, "export_path") + row = layout.row() - row.operator("bim.execute_ifc_clash") + op = row.operator("bim.execute_ifc_clash") + op.filepath = props.export_path row = layout.row() row.label(text=f"{len(clash_set.clashes)} Clashes Found", icon="PIVOT_CURSOR")