mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
New UI to run BIMTester from BlenderBIM Add-on
This commit is contained in:
@@ -34,9 +34,9 @@ def run_tests(args):
|
|||||||
print('No features could be found to check.')
|
print('No features could be found to check.')
|
||||||
return False
|
return False
|
||||||
behave_args = [get_resource_path('features')]
|
behave_args = [get_resource_path('features')]
|
||||||
if args.advanced_arguments:
|
if args['advanced_arguments']:
|
||||||
behave_args.extend(args.advanced_arguments.split())
|
behave_args.extend(args['advanced_arguments'].split())
|
||||||
elif not args.console:
|
elif not args['console']:
|
||||||
behave_args.extend(['--format', 'json.pretty', '--outfile', 'report/report.json'])
|
behave_args.extend(['--format', 'json.pretty', '--outfile', 'report/report.json'])
|
||||||
behave_main(behave_args)
|
behave_main(behave_args)
|
||||||
print('# All tests are finished.')
|
print('# All tests are finished.')
|
||||||
@@ -49,10 +49,10 @@ def get_features(args):
|
|||||||
for f in os.listdir(features_dir):
|
for f in os.listdir(features_dir):
|
||||||
if f.endswith('.feature'):
|
if f.endswith('.feature'):
|
||||||
os.remove(os.path.join(features_dir, f))
|
os.remove(os.path.join(features_dir, f))
|
||||||
if args.feature:
|
if args['feature']:
|
||||||
shutil.copyfile(args.feature, os.path.join(
|
shutil.copyfile(args['feature'], os.path.join(
|
||||||
get_resource_path('features'),
|
get_resource_path('features'),
|
||||||
os.path.basename(args.feature)))
|
os.path.basename(args['feature'])))
|
||||||
return True
|
return True
|
||||||
if os.path.exists('features'):
|
if os.path.exists('features'):
|
||||||
shutil.copytree('features', get_resource_path('features'))
|
shutil.copytree('features', get_resource_path('features'))
|
||||||
@@ -61,7 +61,7 @@ def get_features(args):
|
|||||||
for f in os.listdir('.'):
|
for f in os.listdir('.'):
|
||||||
if not f.endswith('.feature'):
|
if not f.endswith('.feature'):
|
||||||
continue
|
continue
|
||||||
if args.feature and args.feature != f:
|
if args['feature'] and args['feature'] != f:
|
||||||
continue
|
continue
|
||||||
has_features = True
|
has_features = True
|
||||||
shutil.copyfile(f, os.path.join(
|
shutil.copyfile(f, os.path.join(
|
||||||
@@ -70,7 +70,7 @@ def get_features(args):
|
|||||||
return has_features
|
return has_features
|
||||||
|
|
||||||
|
|
||||||
def generate_report(args):
|
def generate_report():
|
||||||
print('# Generating HTML reports now.')
|
print('# Generating HTML reports now.')
|
||||||
if not os.path.exists('report'):
|
if not os.path.exists('report'):
|
||||||
os.mkdir('report')
|
os.mkdir('report')
|
||||||
@@ -197,12 +197,12 @@ parser.add_argument(
|
|||||||
type=str,
|
type=str,
|
||||||
help='Specify your own arguments to Python\'s Behave',
|
help='Specify your own arguments to Python\'s Behave',
|
||||||
default='')
|
default='')
|
||||||
args = parser.parse_args()
|
args = vars(parser.parse_args())
|
||||||
|
|
||||||
if args.purge:
|
if args['purge']:
|
||||||
TestPurger().purge()
|
TestPurger().purge()
|
||||||
elif args.report:
|
elif args['report']:
|
||||||
generate_report(args)
|
generate_report()
|
||||||
else:
|
else:
|
||||||
run_tests(args)
|
run_tests(args)
|
||||||
print('# All tasks are complete :-)')
|
print('# All tasks are complete :-)')
|
||||||
|
|||||||
@@ -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/collision.py
|
||||||
cd dist/blenderbim/libs/site/packages/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcclash/ifcclash.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/ifcdiff/ifcdiff.py
|
||||||
cd dist/blenderbim/libs/site/packages/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifccsv/ifccsv.py
|
cd dist/blenderbim/libs/site/packages/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifccsv/ifccsv.py
|
||||||
|
|
||||||
|
|||||||
@@ -161,6 +161,8 @@ if bpy is not None:
|
|||||||
operator.PushRepresentation,
|
operator.PushRepresentation,
|
||||||
operator.ConvertLocalToGlobal,
|
operator.ConvertLocalToGlobal,
|
||||||
operator.GuessQuantity,
|
operator.GuessQuantity,
|
||||||
|
operator.ExecuteBIMTester,
|
||||||
|
operator.BIMTesterPurge,
|
||||||
prop.StrProperty,
|
prop.StrProperty,
|
||||||
prop.Variable,
|
prop.Variable,
|
||||||
prop.Role,
|
prop.Role,
|
||||||
|
|||||||
@@ -3161,3 +3161,39 @@ class GuessQuantity(bpy.types.Operator):
|
|||||||
prop.string_value = str(round(qto_calculator.guess_quantity(
|
prop.string_value = str(round(qto_calculator.guess_quantity(
|
||||||
prop.name, [p.name for p in props], bpy.context.active_object), 3))
|
prop.name, [p.name for p in props], bpy.context.active_object), 3))
|
||||||
return {'FINISHED'}
|
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'}
|
||||||
|
|||||||
@@ -1348,6 +1348,14 @@ class BIM_PT_qa(Panel):
|
|||||||
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(bim_properties, "scenario")
|
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:")
|
layout.label(text="Quality Auditing:")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user