From a016f6e5c899d328f8dec8c507fa8307a5fef742 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sun, 5 Oct 2025 18:44:14 +1100 Subject: [PATCH] Fix #7186. Support upgrading IFC2X3 IfcExtendedMaterialProperties to IFC4 --- .../ifcopenshell/util/attribute_4_to_2x3.json | 2 +- .../ifcopenshell/util/class_2x3_to_4.json | 1 + .../test/util/test_schema.py | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/attribute_4_to_2x3.json b/src/ifcopenshell-python/ifcopenshell/util/attribute_4_to_2x3.json index 5cf025688c..6de4567868 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/attribute_4_to_2x3.json +++ b/src/ifcopenshell-python/ifcopenshell/util/attribute_4_to_2x3.json @@ -173,7 +173,7 @@ "Identification": "ItemReference" }, "IfcMaterialProperties": { - "Name": "Material" + "Properties": "ExtendedProperties" }, "IfcBlobTexture": { "Mode": "TextureType", diff --git a/src/ifcopenshell-python/ifcopenshell/util/class_2x3_to_4.json b/src/ifcopenshell-python/ifcopenshell/util/class_2x3_to_4.json index e3b6cba1df..3addf1516f 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/class_2x3_to_4.json +++ b/src/ifcopenshell-python/ifcopenshell/util/class_2x3_to_4.json @@ -5,4 +5,5 @@ , "IfcAnnotationSurfaceOccurrence": "IfcStyledItem" , "IfcAnnotationSymbolOccurrence": "IfcStyledItem" , "IfcAnnotationTextOccurrence": "IfcStyledItem" + , "IfcExtendedMaterialProperties": "IfcMaterialProperties" } diff --git a/src/ifcopenshell-python/test/util/test_schema.py b/src/ifcopenshell-python/test/util/test_schema.py index 071ffb8cea..aa24de6360 100644 --- a/src/ifcopenshell-python/test/util/test_schema.py +++ b/src/ifcopenshell-python/test/util/test_schema.py @@ -118,3 +118,20 @@ END-ISO-10303-21; assert qt_float_count_measure_ifc4x3.is_a("IfcQuantityNumber") assert isinstance(qt_float_count_measure_ifc4x3[3], float) assert qt_float_count_measure_ifc4x3[3] == 723.0 + + def test_migrate_extended_material_properties_ifc2x3_ifc4(self): + ifc2x3_file = ifcopenshell.api.project.create_file(version="IFC2X3") + material = ifc2x3_file.createIfcMaterial(Name="Material") + props = [ifc2x3_file.createIfcPropertySingleValue(Name="Foo")] + original_element = ifc2x3_file.createIfcExtendedMaterialProperties(Material=material, ExtendedProperties=props) + ifc4_file = ifcopenshell.api.project.create_file() + + migrator = subject.Migrator() + for element in ifc2x3_file: + migrator.migrate(element, ifc4_file) + + new_element = ifc4_file.by_type("IfcMaterialProperties")[0] + assert new_element.Material.is_a("IfcMaterial") + assert new_element.Material.Name == "Material" + assert new_element.Properties[0].is_a("IfcPropertySingleValue") + assert new_element.Properties[0].Name == "Foo"