From 837c401116a69b8dc27c0535f842491fd5e5c118 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 1 Sep 2023 17:28:19 +1000 Subject: [PATCH] Add filepath popup when saving IDS reports to BCF --- .../blenderbim/bim/module/tester/operator.py | 26 ++++++++----------- src/blenderbim/blenderbim/tool/tester.py | 22 ++++++++++++++++ 2 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 src/blenderbim/blenderbim/tool/tester.py diff --git a/src/blenderbim/blenderbim/bim/module/tester/operator.py b/src/blenderbim/blenderbim/bim/module/tester/operator.py index 71150627dc..4b88c3ae4b 100644 --- a/src/blenderbim/blenderbim/bim/module/tester/operator.py +++ b/src/blenderbim/blenderbim/bim/module/tester/operator.py @@ -68,6 +68,7 @@ class ExecuteIfcTester(bpy.types.Operator, tool.Ifc.Operator): report = None report = ifctester.reporter.Json(specs).report()["specifications"] if report: + tool.Tester.specs = specs tool.Tester.report = report props.specifications.clear() for spec in report: @@ -155,21 +156,16 @@ class ExportBcf(bpy.types.Operator): bl_idname = "bim.export_bcf" bl_label = "Export BCF" bl_options = {"REGISTER", "UNDO"} + filter_glob: bpy.props.StringProperty(default="*.bcf", options={"HIDDEN"}) + filepath: bpy.props.StringProperty(subtype="FILE_PATH") def execute(self, context): - props = context.scene.IfcTesterProperties - if tool.Ifc.get(): - ifc = tool.Ifc.get() - else: - ifc = ifcopenshell.open(props.ifc_file) - with tempfile.TemporaryDirectory() as dirpath: - output = os.path.join(dirpath, "{}.bcf".format(props.specs)) - specs = ifctester.ids.open(props.specs) - specs.validate(ifc) - bcf_reporter = ifctester.reporter.Bcf(specs) - bcf_reporter.report() - bcf_reporter.to_file(output) - print("Finished exporting!") - self.report({"INFO"}, "Finished exporting!") - + bcf_reporter = ifctester.reporter.Bcf(tool.Tester.specs) + bcf_reporter.report() + bcf_reporter.to_file(self.filepath) + self.report({"INFO"}, "Finished exporting!") return {"FINISHED"} + + def invoke(self, context, event): + context.window_manager.fileselect_add(self) + return {"RUNNING_MODAL"} diff --git a/src/blenderbim/blenderbim/tool/tester.py b/src/blenderbim/blenderbim/tool/tester.py new file mode 100644 index 0000000000..f6f66e97ce --- /dev/null +++ b/src/blenderbim/blenderbim/tool/tester.py @@ -0,0 +1,22 @@ +# BlenderBIM Add-on - OpenBIM Blender Add-on +# Copyright (C) 2021 Dion Moult +# +# This file is part of BlenderBIM Add-on. +# +# BlenderBIM Add-on is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# BlenderBIM Add-on is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with BlenderBIM Add-on. If not, see . + + +class Tester: + specs = None + report = {}