diff --git a/src/ifcbimtester/bimtester/run.py b/src/ifcbimtester/bimtester/run.py index 6b2411b31f..ad41ecfd90 100644 --- a/src/ifcbimtester/bimtester/run.py +++ b/src/ifcbimtester/bimtester/run.py @@ -3,8 +3,13 @@ import sys import shutil import tempfile import ifcopenshell +try: + import ifcopenshell.express +except: + pass # They are using an old version of IfcOpenShell. Gracefully degrade for now. import behave.formatter.pretty # Needed for pyinstaller to package it from bimtester.ifc import IfcStore +from distutils.dir_util import copy_tree from behave.__main__ import main as behave_main @@ -14,7 +19,6 @@ class TestRunner: IfcStore.file = ifc if ifc else ifcopenshell.open(ifc_path) if schema: - import ifcopenshell.express schema = ifcopenshell.express.parse(path) ifcopenshell.register_schema(schema) @@ -29,9 +33,15 @@ class TestRunner: def run(self, args): tmpdir = tempfile.mkdtemp() features_path = os.path.join(tmpdir, "features") + steps_path = os.path.join(features_path, "steps") report_json = os.path.join(tmpdir, "report.json") shutil.copytree(os.path.join(self.base_path, "features"), features_path) shutil.copy(args["feature"], features_path) + if args["steps"]: + if os.path.isfile(args["steps"]): + shutil.copy(args["steps"], steps_path) + elif os.path.isdir(args["steps"]): + copy_tree(args["steps"], steps_path) behave_main(self.get_behave_args(args, features_path, report_json)) return report_json diff --git a/src/ifcbimtester/cli.py b/src/ifcbimtester/cli.py old mode 100755 new mode 100644 index 4671c8054b..5fff1cb6ce --- a/src/ifcbimtester/cli.py +++ b/src/ifcbimtester/cli.py @@ -14,6 +14,7 @@ parser.add_argument("-f", "--feature", type=str, help="Specify a feature file to parser.add_argument("-i", "--ifc", type=str, help="Specify a ifc file", required=True) parser.add_argument("-p", "--path", type=str, help="Define a path for use in tests") parser.add_argument("-r", "--report", type=str, help="Specify an output file for a HTML report") +parser.add_argument("--steps", type=str, help="Specify custom step definitions") parser.add_argument("--schema", type=str, help="Specify an output file for a HTML report") parser.add_argument("--lang", type=str, help="Specify a language", default="") diff --git a/src/ifcblenderexport/blenderbim/bim/module/bimtester/__init__.py b/src/ifcblenderexport/blenderbim/bim/module/bimtester/__init__.py index 2a1c4bf008..42feab2dcb 100644 --- a/src/ifcblenderexport/blenderbim/bim/module/bimtester/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/module/bimtester/__init__.py @@ -5,6 +5,7 @@ classes = ( operator.ExecuteBIMTester, operator.BIMTesterPurge, operator.SelectFeature, + operator.SelectSteps, operator.SelectBIMTesterIfcFile, operator.RejectElement, operator.ApproveClass, diff --git a/src/ifcblenderexport/blenderbim/bim/module/bimtester/operator.py b/src/ifcblenderexport/blenderbim/bim/module/bimtester/operator.py index 0ec0a4cf4f..133a44c124 100644 --- a/src/ifcblenderexport/blenderbim/bim/module/bimtester/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/module/bimtester/operator.py @@ -29,7 +29,8 @@ class ExecuteBIMTester(bpy.types.Operator): "path": "", "report": report, "schema": "", - "lang": "en" + "lang": "en", + "steps": props.steps } use_stored_ifc = props.should_load_from_memory and IfcStore.get_file() runner = bimtester.run.TestRunner(args["ifc"], ifc=IfcStore.get_file() if use_stored_ifc else None) @@ -71,6 +72,22 @@ class SelectFeature(bpy.types.Operator): return {"RUNNING_MODAL"} +class SelectSteps(bpy.types.Operator): + bl_idname = "bim.select_steps" + bl_label = "Select Steps" + filename_ext = ".py" + filter_glob: bpy.props.StringProperty(default="*.py", options={"HIDDEN"}) + filepath: bpy.props.StringProperty(subtype="FILE_PATH") + + def execute(self, context): + bpy.context.scene.BimTesterProperties.steps = self.filepath + return {"FINISHED"} + + def invoke(self, context, event): + context.window_manager.fileselect_add(self) + return {"RUNNING_MODAL"} + + class SelectBIMTesterIfcFile(bpy.types.Operator): bl_idname = "bim.select_bimtester_ifc_file" bl_label = "Select BIMTester IFC File" diff --git a/src/ifcblenderexport/blenderbim/bim/module/bimtester/prop.py b/src/ifcblenderexport/blenderbim/bim/module/bimtester/prop.py index 95a53a4578..c42f56f29f 100644 --- a/src/ifcblenderexport/blenderbim/bim/module/bimtester/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/module/bimtester/prop.py @@ -42,6 +42,7 @@ def refreshScenarios(self, context): class BimTesterProperties(PropertyGroup): feature: StringProperty(default="", name="Feature File", update=refreshScenarios) + steps: StringProperty(default="", name="Custom Steps") ifc_file: StringProperty(default="", name="IFC File") audit_ifc_class: EnumProperty(items=getIfcClasses, name="Audit Class") qa_reject_element_reason: StringProperty(name="Element Rejection Reason") diff --git a/src/ifcblenderexport/blenderbim/bim/module/bimtester/ui.py b/src/ifcblenderexport/blenderbim/bim/module/bimtester/ui.py index b660fbcb7f..b1508ad84f 100644 --- a/src/ifcblenderexport/blenderbim/bim/module/bimtester/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/module/bimtester/ui.py @@ -28,6 +28,10 @@ class BIM_PT_qa(Panel): row.prop(props, "feature") row.operator("bim.select_feature", icon="FILE_FOLDER", text="") + row = self.layout.row(align=True) + row.prop(props, "steps") + row.operator("bim.select_steps", icon="FILE_FOLDER", text="") + has_ifc_file = (IfcStore.get_file() and props.should_load_from_memory) or ( props.ifc_file and not props.should_load_from_memory )