mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
[BlenderBIM] Update IfcTester (2023_07_21) (#3489)
This commit is contained in:
@@ -58,10 +58,11 @@ class ExecuteIfcTester(bpy.types.Operator):
|
||||
print("Finished validating:", time.time() - start)
|
||||
start = time.time()
|
||||
|
||||
engine = ifctester.reporter.Html(specs)
|
||||
engine.report()
|
||||
engine.to_file(output)
|
||||
webbrowser.open("file://" + output)
|
||||
if props.generate_html_report:
|
||||
engine = ifctester.reporter.Html(specs)
|
||||
engine.report()
|
||||
engine.to_file(output)
|
||||
webbrowser.open("file://" + output)
|
||||
|
||||
report = None
|
||||
report = ifctester.reporter.Json(specs).report()['specifications']
|
||||
@@ -155,18 +156,19 @@ class ExportBcf(bpy.types.Operator):
|
||||
|
||||
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))
|
||||
if props.should_load_from_memory and tool.Ifc.get():
|
||||
ifc = tool.Ifc.get()
|
||||
else:
|
||||
ifc = ifcopenshell.open(props.ifc_file)
|
||||
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:")
|
||||
print("Finished exporting!")
|
||||
self.report({"INFO"}, 'Finished exporting!')
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -49,8 +49,10 @@ class FailedEntities(PropertyGroup):
|
||||
class IfcTesterProperties(PropertyGroup):
|
||||
specs: StringProperty(default="", name="IDS File")
|
||||
ifc_file: StringProperty(default="", name="IFC File")
|
||||
should_load_from_memory: BoolProperty(default=False, name="Load from Memory",
|
||||
|
||||
should_load_from_memory: BoolProperty(default=False, name="Load from Memory",
|
||||
description="Use the currently opened IFC project. Required for the detailed Tester UI")
|
||||
generate_html_report: BoolProperty(default=False, name="Generate HTML report")
|
||||
|
||||
active_specification_index: IntProperty(name="Active Specification Index")
|
||||
active_requirement_index: IntProperty(name="Active Requirement Index")
|
||||
|
||||
@@ -32,38 +32,39 @@ class BIM_PT_tester(Panel):
|
||||
|
||||
def draw(self, context):
|
||||
self.layout.use_property_split = True
|
||||
|
||||
self.props = context.scene.IfcTesterProperties
|
||||
props = context.scene.IfcTesterProperties
|
||||
|
||||
row = self.layout.row()
|
||||
row.prop(self.props, "should_load_from_memory")
|
||||
row.enabled = bool(tool.Ifc.get())
|
||||
|
||||
row = self.layout.row()
|
||||
row.prop(props, "generate_html_report")
|
||||
|
||||
if not tool.Ifc.get() or not self.props.should_load_from_memory:
|
||||
|
||||
if not tool.Ifc.get() or not props.should_load_from_memory:
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(self.props, "ifc_file")
|
||||
row.prop(props, "ifc_file")
|
||||
row.operator("bim.select_ifctester_ifc_file", icon="FILE_FOLDER", text="")
|
||||
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(self.props, "specs")
|
||||
row.prop(props, "specs")
|
||||
row.operator("bim.select_specs", icon="FILE_FOLDER", text="")
|
||||
|
||||
row = self.layout.row()
|
||||
row.operator("bim.execute_ifc_tester")
|
||||
|
||||
if self.props.has_report and self.props.should_load_from_memory:
|
||||
if props.has_report:
|
||||
self.layout.template_list(
|
||||
"BIM_UL_tester_specifications",
|
||||
"",
|
||||
self.props,
|
||||
props,
|
||||
"specifications",
|
||||
self.props,
|
||||
props,
|
||||
"active_specification_index",
|
||||
)
|
||||
|
||||
self.draw_editable_ui(context)
|
||||
|
||||
if self.props.has_report:
|
||||
row = self.layout.row()
|
||||
row.operator("bim.export_bcf", text="Export BCF", icon="EXPORT")
|
||||
|
||||
@@ -101,9 +102,9 @@ class BIM_PT_tester(Panel):
|
||||
self.layout.template_list(
|
||||
"BIM_UL_tester_failed_entities",
|
||||
"",
|
||||
self.props,
|
||||
props,
|
||||
"failed_entities",
|
||||
self.props,
|
||||
props,
|
||||
"active_failed_entity_index",
|
||||
)
|
||||
|
||||
@@ -121,14 +122,21 @@ class BIM_UL_tester_specifications(UIList):
|
||||
|
||||
class BIM_UL_tester_failed_entities(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
ifc_file = tool.Ifc.get()
|
||||
props = context.scene.IfcTesterProperties
|
||||
if item:
|
||||
ifc_id = int(item.element[1:item.element.find('=')])
|
||||
entity = ifc_file.by_id(ifc_id)
|
||||
if props.should_load_from_memory:
|
||||
ifc_file = tool.Ifc.get()
|
||||
ifc_id = int(item.element[1:item.element.find('=')])
|
||||
entity = ifc_file.by_id(ifc_id)
|
||||
report_entity = f'[#{ifc_id}][{entity.is_a()}] {entity.Name}'
|
||||
else:
|
||||
report_entity = item.element
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.label(text=f'{entity.Name} [{entity.is_a()}]')
|
||||
row.label(text=report_entity)
|
||||
row.label(text=item.reason)
|
||||
op = row.operator("bim.select_entity", text="", icon="RESTRICT_SELECT_OFF")
|
||||
op.ifc_id = entity.id()
|
||||
if props.should_load_from_memory:
|
||||
op = row.operator("bim.select_entity", text="", icon="RESTRICT_SELECT_OFF")
|
||||
op.ifc_id = entity.id()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user