diff --git a/src/ifcbimtester/bimtester.py b/src/ifcbimtester/bimtester.py index ebea0b5dd6..4170187f56 100644 --- a/src/ifcbimtester/bimtester.py +++ b/src/ifcbimtester/bimtester.py @@ -34,9 +34,9 @@ def run_tests(args): print('No features could be found to check.') return False behave_args = [get_resource_path('features')] - if args.advanced_arguments: - behave_args.extend(args.advanced_arguments.split()) - elif not args.console: + if args['advanced_arguments']: + behave_args.extend(args['advanced_arguments'].split()) + elif not args['console']: behave_args.extend(['--format', 'json.pretty', '--outfile', 'report/report.json']) behave_main(behave_args) print('# All tests are finished.') @@ -49,10 +49,10 @@ def get_features(args): for f in os.listdir(features_dir): if f.endswith('.feature'): os.remove(os.path.join(features_dir, f)) - if args.feature: - shutil.copyfile(args.feature, os.path.join( + if args['feature']: + shutil.copyfile(args['feature'], os.path.join( get_resource_path('features'), - os.path.basename(args.feature))) + os.path.basename(args['feature']))) return True if os.path.exists('features'): shutil.copytree('features', get_resource_path('features')) @@ -61,7 +61,7 @@ def get_features(args): for f in os.listdir('.'): if not f.endswith('.feature'): continue - if args.feature and args.feature != f: + if args['feature'] and args['feature'] != f: continue has_features = True shutil.copyfile(f, os.path.join( @@ -70,7 +70,7 @@ def get_features(args): return has_features -def generate_report(args): +def generate_report(): print('# Generating HTML reports now.') if not os.path.exists('report'): os.mkdir('report') @@ -197,12 +197,12 @@ parser.add_argument( type=str, help='Specify your own arguments to Python\'s Behave', default='') -args = parser.parse_args() +args = vars(parser.parse_args()) -if args.purge: +if args['purge']: TestPurger().purge() -elif args.report: - generate_report(args) +elif args['report']: + generate_report() else: run_tests(args) print('# All tasks are complete :-)') diff --git a/src/ifcblenderexport/Makefile b/src/ifcblenderexport/Makefile index 2ae232694c..6938080a42 100644 --- a/src/ifcblenderexport/Makefile +++ b/src/ifcblenderexport/Makefile @@ -182,6 +182,35 @@ endif cd dist/blenderbim/libs/site/packages/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcclash/collision.py cd dist/blenderbim/libs/site/packages/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcclash/ifcclash.py + # Required by BIMTester + mkdir dist/working + cd dist/working && wget https://files.pythonhosted.org/packages/c8/4b/d0a8c23b6c8985e5544ea96d27105a273ea22051317f850c2cdbf2029fe4/behave-1.2.6.tar.gz + cd dist/working && tar -xzvf behave* + cd dist/working/behave-1.2.6/ && cp -r behave ../../blenderbim/libs/site/packages/ + rm -rf dist/working + + # Required by behave + mkdir dist/working + cd dist/working && wget https://files.pythonhosted.org/packages/f4/65/220bb4075fddb09d5b3ea2c1c1fa66c1c72be9361ec187aab50fa161e576/parse-1.15.0.tar.gz + cd dist/working && tar -xzvf parse* + cd dist/working/parse-1.15.0/ && cp parse.py ../../blenderbim/libs/site/packages/ + rm -rf dist/working + + # Required by behave + mkdir dist/working + cd dist/working && wget https://files.pythonhosted.org/packages/2e/79/81bebd1b0446d46733db99d74543b4bb80646ef4c988584bae0862e706bc/parse_type-0.5.2.tar.gz + cd dist/working && tar -xzvf parse_type* + cd dist/working/parse_type-0.5.2/ && cp -r parse_type ../../blenderbim/libs/site/packages/ + rm -rf dist/working + + # Supplies BIMTester functionality + cd dist/blenderbim/libs/site/packages/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcbimtester/bimtester.py + mkdir dist/blenderbim/libs/site/packages/features/ + mkdir dist/blenderbim/libs/site/packages/features/steps/ + cd dist/blenderbim/libs/site/packages/features/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcbimtester/features/environment.py + cd dist/blenderbim/libs/site/packages/features/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcbimtester/features/template.html + cd dist/blenderbim/libs/site/packages/features/steps/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcbimtester/features/steps/steps.py + cd dist/blenderbim/libs/site/packages/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcdiff/ifcdiff.py cd dist/blenderbim/libs/site/packages/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifccsv/ifccsv.py diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index 60b979e42f..256f699259 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -161,6 +161,8 @@ if bpy is not None: operator.PushRepresentation, operator.ConvertLocalToGlobal, operator.GuessQuantity, + operator.ExecuteBIMTester, + operator.BIMTesterPurge, prop.StrProperty, prop.Variable, prop.Role, diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index 64eb348bf9..bbb65f5c87 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -3161,3 +3161,39 @@ class GuessQuantity(bpy.types.Operator): prop.string_value = str(round(qto_calculator.guess_quantity( prop.name, [p.name for p in props], bpy.context.active_object), 3)) return {'FINISHED'} + + +class ExecuteBIMTester(bpy.types.Operator): + bl_idname = 'bim.execute_bim_tester' + bl_label = 'Execute BIMTester' + + def execute(self, context): + import bimtester + filename = os.path.join( + bpy.context.scene.BIMProperties.features_dir, + bpy.context.scene.BIMProperties.features_file + '.feature') + cwd = os.getcwd() + os.chdir(bpy.context.scene.BIMProperties.features_dir) + bimtester.run_tests({'feature': filename, 'advanced_arguments': None, 'console': False}) + bimtester.generate_report() + webbrowser.open(os.path.join( + bpy.context.scene.BIMProperties.features_dir, + 'report', bpy.context.scene.BIMProperties.features_file + '.feature.html')) + os.chdir(cwd) + return {'FINISHED'} + + +class BIMTesterPurge(bpy.types.Operator): + bl_idname = 'bim.bim_tester_purge' + bl_label = 'Purge Tests' + + def execute(self, context): + import bimtester + filename = os.path.join( + bpy.context.scene.BIMProperties.features_dir, + bpy.context.scene.BIMProperties.features_file + '.feature') + cwd = os.getcwd() + os.chdir(bpy.context.scene.BIMProperties.features_dir) + bimtester.TestPurger().purge() + os.chdir(cwd) + return {'FINISHED'} diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index d7417197bf..2ccfac69d7 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -1348,6 +1348,14 @@ class BIM_PT_qa(Panel): row = layout.row(align=True) row.prop(bim_properties, "scenario") + else: + return + + row = layout.row() + row.operator("bim.execute_bim_tester") + + row = layout.row() + row.operator("bim.bim_tester_purge") layout.label(text="Quality Auditing:")