From 11c6b55f7c1e57dec568d57e0928ed2cc235ad6e Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 10 Feb 2025 17:26:51 +1100 Subject: [PATCH] Revise the modern COBie 2.4 implementation to also allow PointOfContact/WarrantyPeriod Legacy COBie 2.4 allowed this but not sure why it dropped off. --- src/ifcfm/ifcfm/cobie24.py | 23 ++++++++++++++++------- src/ifcfm/ifcfm/cobie24legacy.py | 6 ++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/ifcfm/ifcfm/cobie24.py b/src/ifcfm/ifcfm/cobie24.py index 25166191e4..8eed8f801a 100644 --- a/src/ifcfm/ifcfm/cobie24.py +++ b/src/ifcfm/ifcfm/cobie24.py @@ -486,12 +486,11 @@ def get_type_data(ifc_file: ifcopenshell.file, element: ifcopenshell.entity_inst sustainability_performance = None for pset_name, props in ifcopenshell.util.element.get_psets(element).items(): - pset_warranty_type = None if pset_name == "COBie_Warranty": - warranty_guarantor_parts = props.get("WarrantyGuarantorParts", None) - warranty_guarantor_labor = props.get("WarrantyGuarantorLabor", None) - warranty_duration_parts = props.get("WarrantyDurationParts", None) - warranty_duration_labor = props.get("WarrantyDurationLabor", None) + warranty_guarantor_parts = warranty_guarantor_parts or props.get("WarrantyGuarantorParts", None) + warranty_guarantor_labor = warranty_guarantor_labor or props.get("WarrantyGuarantorLabor", None) + warranty_duration_parts = warranty_duration_parts or props.get("WarrantyDurationParts", None) + warranty_duration_labor = warranty_duration_labor or props.get("WarrantyDurationLabor", None) warranty_duration_unit = props.get("WarrantyDurationUnit", None) warranty_description = props.get("WarrantyDescription", None) elif pset_name == "COBie_Asset": @@ -522,6 +521,18 @@ def get_type_data(ifc_file: ifcopenshell.file, element: ifcopenshell.entity_inst manufacturer = props.get("Manufacturer", None) model_number = props.get("ModelLabel", None) model_reference = props.get("ModelReference", None) + elif pset_name == "Pset_Warranty": + # The legacy COBie 2.4 relied on WarrantyIdentifier. This is almost + # certainly a mistake since you can only have a single property set + # of the same name, so it's not possible to have two psets + # targeting both parts and labor. In the new version, we do away + # with this, assuming the user either specifically targets + # COBie_Waranty, or if they use the built-in Pset_Warranty, we + # assume it affects both type sof warranty. + warranty_guarantor_parts = warranty_guarantor_parts or props.get("PointOfContact", None) + warranty_guarantor_labor = warranty_guarantor_labor or props.get("PointOfContact", None) + warranty_duration_parts = warranty_duration_parts or props.get("WarrantyPeriod", None) + warranty_duration_labor = warranty_duration_labor or props.get("WarrantyPeriod", None) return { "Name": val(element.Name), @@ -565,8 +576,6 @@ def get_type_data(ifc_file: ifcopenshell.file, element: ifcopenshell.entity_inst def get_component_data(ifc_file: ifcopenshell.file, element: ifcopenshell.entity_instance) -> dict[str, Any]: space = ifcopenshell.util.element.get_container(element) space_name = space.Name if space.is_a("IfcSpace") else None - systems = ifcopenshell.util.system.get_element_systems(element) - system = systems[0].Name if systems else None type_name = None relating_type = ifcopenshell.util.element.get_type(element) diff --git a/src/ifcfm/ifcfm/cobie24legacy.py b/src/ifcfm/ifcfm/cobie24legacy.py index ea8a077b1f..6e5eaf84c2 100644 --- a/src/ifcfm/ifcfm/cobie24legacy.py +++ b/src/ifcfm/ifcfm/cobie24legacy.py @@ -571,7 +571,7 @@ def get_type_data(ifc_file: ifcopenshell.file, element: ifcopenshell.entity_inst if pset_warranty_type == "parts" and val(value): if name == "PointOfContact": # https://github.com/buildingSMART/IFC4.3.x-development/issues/698 - warranty_guarantor_parts = str(value) + pset_metadata["warranty_guarantor_parts"] = str(value) elif name == "WarrantyPeriod": warranty_duration_parts = str(value) unit = get_property_unit(pset, name) @@ -579,7 +579,7 @@ def get_type_data(ifc_file: ifcopenshell.file, element: ifcopenshell.entity_inst elif pset_warranty_type == "labor" and val(value): if name == "PointOfContact": # https://github.com/buildingSMART/IFC4.3.x-development/issues/698 - warranty_guarantor_labor = str(value) + pset_metadata["warranty_guarantor_labor"] = str(value) elif name == "WarrantyPeriod": warranty_duration_labor = str(value) unit = get_property_unit(pset, name) @@ -635,8 +635,6 @@ def get_type_data(ifc_file: ifcopenshell.file, element: ifcopenshell.entity_inst def get_component_data(ifc_file: ifcopenshell.file, element: ifcopenshell.entity_instance) -> dict[str, Any]: space = ifcopenshell.util.element.get_container(element) space_name = space.Name if space.is_a("IfcSpace") else None - systems = ifcopenshell.util.system.get_element_systems(element) - system = systems[0].Name if systems else None type_name = None relating_type = ifcopenshell.util.element.get_type(element)