From 26b21ddcb3eeef4632b412471d15e5f45c925026 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sun, 23 Mar 2025 22:16:42 +1100 Subject: [PATCH] Fix #6414. Allow extracting elements from non-standard IFC schemas. --- src/ifcpatch/ifcpatch/recipes/ExtractElements.py | 2 +- src/ifcpatch/test/test_ExtractElements.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ifcpatch/ifcpatch/recipes/ExtractElements.py b/src/ifcpatch/ifcpatch/recipes/ExtractElements.py index e2dfb13866..0218d68a30 100644 --- a/src/ifcpatch/ifcpatch/recipes/ExtractElements.py +++ b/src/ifcpatch/ifcpatch/recipes/ExtractElements.py @@ -55,7 +55,7 @@ class Patcher: def patch(self): self.contained_ins: dict[str, set[ifcopenshell.entity_instance]] = {} self.aggregates: dict[str, set[ifcopenshell.entity_instance]] = {} - self.new = ifcopenshell.file(schema=self.file.schema_identifier) + self.new = ifcopenshell.file(schema_version=self.file.schema_version) self.owner_history = None self.reuse_identities: dict[int, ifcopenshell.entity_instance] = {} for owner_history in self.file.by_type("IfcOwnerHistory"): diff --git a/src/ifcpatch/test/test_ExtractElements.py b/src/ifcpatch/test/test_ExtractElements.py index 10b55bad09..97f416ae3f 100644 --- a/src/ifcpatch/test/test_ExtractElements.py +++ b/src/ifcpatch/test/test_ExtractElements.py @@ -75,6 +75,14 @@ class TestExtractElements(test.bootstrap.IFC4): assert output.by_type("IfcWall") assert not output.by_type("IfcSlab") + def test_extracting_non_standard_schema_version(self): + self.file = ifcopenshell.file(schema_version=(4, 3, 0, 0)) + project = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject") + wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall") + output = ifcpatch.execute({"file": self.file, "recipe": "ExtractElements", "arguments": ["IfcWall"]}) + assert output.by_type("IfcProject")[0].GlobalId == project.GlobalId + assert output.by_type("IfcWall")[0].GlobalId == wall.GlobalId + class TestExtractElementsIFC2X3(test.bootstrap.IFC2X3, TestExtractElements): pass