mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 03:14:23 +00:00
bimtester: update log and smartview, they still are deactivated by default, fixes #1892
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
import os
|
||||
|
||||
from behave.model import Scenario
|
||||
from logfile import create_logfile
|
||||
from logfile import append_logfile
|
||||
from zoom_smart_view import append_zoom_smartview
|
||||
from zoom_smart_view import create_zoom_smartview
|
||||
|
||||
from bimtester.ifc import IfcStore
|
||||
from bimtester.lang import switch_locale
|
||||
from logfile import append_logfile
|
||||
from logfile import create_logfile
|
||||
from zoom_smart_view import add_smartview
|
||||
from zoom_smart_view import create_zoom_set_of_smartviews
|
||||
|
||||
|
||||
this_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
||||
def before_all(context):
|
||||
|
||||
userdata = context.config.userdata
|
||||
|
||||
if context.config.lang:
|
||||
@@ -21,34 +22,55 @@ def before_all(context):
|
||||
continue_after_failed = userdata.getbool("runner.continue_after_failed_step", True)
|
||||
Scenario.continue_after_failed_step = continue_after_failed
|
||||
|
||||
# TODO: refactor smart view support into a decoupled module
|
||||
# context.ifc_path = userdata.get("ifc", "")
|
||||
# context.ifc_basename = os.path.basename(
|
||||
# os.path.splitext(context.ifc_path)[0]
|
||||
# )
|
||||
context.ifcfile_basename = os.path.basename(
|
||||
os.path.splitext(userdata["ifc"])[0]
|
||||
)
|
||||
context.outpath = os.path.join(this_path, "..")
|
||||
context.create_log = False
|
||||
context.create_smartview = False
|
||||
|
||||
# context.outpath = os.path.join(this_path, "..")
|
||||
if context.create_log is True:
|
||||
# set up log file
|
||||
context.thelogfile = os.path.join(
|
||||
context.outpath,
|
||||
context.ifcfile_basename + ".log"
|
||||
)
|
||||
create_logfile(
|
||||
context.thelogfile,
|
||||
context.ifcfile_basename,
|
||||
)
|
||||
|
||||
# context.thelogfile = os.path.join(context.outpath, context.ifc_basename + ".log")
|
||||
# create_logfile(
|
||||
# context.thelogfile,
|
||||
# context.ifc_basename,
|
||||
# )
|
||||
|
||||
# # set up smart view file
|
||||
# context.smview_file = os.path.join(context.outpath, context.ifc_basename + ".bcsv")
|
||||
# create_zoom_smartview(
|
||||
# context.smview_file,
|
||||
# context.ifc_basename,
|
||||
# )
|
||||
def before_feature(context, feature):
|
||||
|
||||
# TODO: refactor zoom smart view support into a decoupled module
|
||||
if context.create_smartview is True:
|
||||
smartview_name = context.ifcfile_basename + "_" + feature.name
|
||||
context.smview_file = os.path.join(
|
||||
context.outpath,
|
||||
smartview_name + ".bcsv"
|
||||
)
|
||||
# print("SmartView file: {}".format(context.smview_file))
|
||||
create_zoom_set_of_smartviews(
|
||||
context.smview_file,
|
||||
smartview_name,
|
||||
)
|
||||
|
||||
|
||||
def after_step(context, step):
|
||||
pass
|
||||
# TODO: refactor smart view support into a decoupled module
|
||||
#if step.status == "failed":
|
||||
# # append log file
|
||||
# append_logfile(context, step)
|
||||
# # extend smart view
|
||||
# if hasattr(context, "falseguids"):
|
||||
# append_zoom_smartview(context.smview_file, step.name, context.falseguids)
|
||||
|
||||
if step.status == "failed" and context.create_log is True:
|
||||
append_logfile(context, step)
|
||||
|
||||
if (
|
||||
step.status == "failed"
|
||||
and context.create_smartview is True
|
||||
and hasattr(context, "falseguids")
|
||||
):
|
||||
# print(context.falseguids)
|
||||
add_smartview(
|
||||
context.smview_file,
|
||||
step.name,
|
||||
context.falseguids
|
||||
)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import fileinput
|
||||
import uuid
|
||||
|
||||
|
||||
def create_zoom_smartview(sm_file, ifcbasename):
|
||||
def create_zoom_set_of_smartviews(sm_file, smartviewset_name):
|
||||
|
||||
# smartviewset_name: is the directory name in Zoom the SmartViews are in
|
||||
|
||||
smf = open(sm_file, "w")
|
||||
smf.write('<?xml version="1.0"?>\n')
|
||||
@@ -14,7 +17,7 @@ def create_zoom_smartview(sm_file, ifcbasename):
|
||||
smf.write("\n")
|
||||
smf.write("<SMARTVIEWSETS>\n")
|
||||
smf.write(" <SMARTVIEWSET>\n")
|
||||
smf.write(" <TITLE>BIMTester {}</TITLE>\n".format(ifcbasename))
|
||||
smf.write(" <TITLE>BIMTester {}</TITLE>\n".format(smartviewset_name))
|
||||
smf.write(" <DESCRIPTION></DESCRIPTION>\n")
|
||||
smf.write(" <GUID>a2ddfaf7-97f2-4519-aabd-f2d94f6b4d6b</GUID>\n")
|
||||
smf.write(" <MODIFICATIONDATE>2020-10-30T13:23:30")
|
||||
@@ -27,16 +30,22 @@ def create_zoom_smartview(sm_file, ifcbasename):
|
||||
smf.close()
|
||||
|
||||
|
||||
def append_zoom_smartview(sm_file, step_name, false_elements_guid):
|
||||
def add_smartview(sm_file, smartview_name, guids):
|
||||
|
||||
# smartview_name: is the name of the SmartView in Zoom
|
||||
# guids: List of guids
|
||||
# model will be grey and transparent, the guids objs will be red and not transparent
|
||||
|
||||
# build the smartview string
|
||||
smview_string = " <SMARTVIEW>\n"
|
||||
smview_string += (
|
||||
" <TITLE>GUID filter, {}</TITLE>\n"
|
||||
.format(step_name)
|
||||
.format(smartview_name)
|
||||
)
|
||||
smview_string += "{}\n".format(each_smartview_string_before)
|
||||
for guid in false_elements_guid:
|
||||
smview_string += "{}\n".format(each_smartview_string_before1)
|
||||
smview_string += str(uuid.uuid4()) # create and add a smart view guid
|
||||
smview_string += "{}\n".format(each_smartview_string_before2)
|
||||
for guid in guids:
|
||||
smview_string += (
|
||||
"{}{}{}\n".format(
|
||||
rule_string_before,
|
||||
@@ -59,11 +68,14 @@ each_smartview_string_title = """ <SMARTVIEW>
|
||||
<DESCRIPTION></DESCRIPTION>"""
|
||||
|
||||
|
||||
each_smartview_string_before = """ <CREATOR>bernd@bimstatik.ch</CREATOR>
|
||||
each_smartview_string_before1 = """ <CREATOR>bernd@bimstatik.ch</CREATOR>
|
||||
<CREATIONDATE>2020-10-30T13:18:45</CREATIONDATE>
|
||||
<MODIFIER>bernd@bimstatik.ch</MODIFIER>
|
||||
<MODIFICATIONDATE>2020-10-30T13:23:30</MODIFICATIONDATE>
|
||||
<GUID>15fda94f-b4bf-43be-8ef4-15d3121137e1</GUID>
|
||||
<GUID>"""
|
||||
|
||||
|
||||
each_smartview_string_before2 = """</GUID>
|
||||
<RULES>
|
||||
<RULE>
|
||||
<IFCTYPE>Any</IFCTYPE>
|
||||
|
||||
Reference in New Issue
Block a user