add export bcf to ifctester (2023_07_18)

This commit is contained in:
c4rlosdias
2023-07-18 13:35:43 -03:00
parent 25d76152f6
commit 36b45b744d
3 changed files with 28 additions and 2 deletions
@@ -25,6 +25,7 @@ classes = (
operator.SelectIfcTesterIfcFile, operator.SelectIfcTesterIfcFile,
operator.SelectRequirement, operator.SelectRequirement,
operator.SelectEntity, operator.SelectEntity,
operator.ExportBcf,
prop.FailedEntities, prop.FailedEntities,
prop.Specification, prop.Specification,
prop.IfcTesterProperties, prop.IfcTesterProperties,
@@ -54,7 +54,6 @@ class ExecuteIfcTester(bpy.types.Operator):
print("Finished loading:", time.time() - start) print("Finished loading:", time.time() - start)
start = time.time() start = time.time()
specs.validate(ifc) specs.validate(ifc)
print(specs)
print("Finished validating:", time.time() - start) print("Finished validating:", time.time() - start)
start = time.time() start = time.time()
@@ -149,3 +148,25 @@ class SelectEntity(bpy.types.Operator):
bpy.context.view_layer.objects.active = obj bpy.context.view_layer.objects.active = obj
return {"FINISHED"} return {"FINISHED"}
class ExportBcf(bpy.types.Operator):
bl_idname = "bim.export_bcf"
bl_label = "Export BCF"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
props = context.scene.IfcTesterProperties
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:")
return {"FINISHED"}
@@ -63,6 +63,10 @@ class BIM_PT_tester(Panel):
self.draw_editable_ui(context) self.draw_editable_ui(context)
if self.props.has_report:
row = self.layout.row()
row.operator("bim.export_bcf", text="Export BCF", icon="EXPORT")
def draw_editable_ui(self, context): def draw_editable_ui(self, context):
props = context.scene.IfcTesterProperties props = context.scene.IfcTesterProperties
i = props.active_specification_index i = props.active_specification_index