Fix #6414. Allow extracting elements from non-standard IFC schemas.

This commit is contained in:
Dion Moult
2025-03-23 22:16:42 +11:00
parent f1138d1aac
commit 26b21ddcb3
2 changed files with 9 additions and 1 deletions
@@ -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"):
@@ -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