ifcpatch - add ifc2x3 tests and test for MergeDuplicateTypes

This commit is contained in:
Andrej730
2024-04-12 10:57:35 +05:00
parent 67a6e4d258
commit 9e310318d4
6 changed files with 181 additions and 79 deletions
+13 -10
View File
@@ -22,27 +22,30 @@ import ifcpatch
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.util.element
import test.bootstrap
class TestRegenerateGlobalIds:
class TestRegenerateGlobalIds(test.bootstrap.IFC4):
def test_run(self):
ifc_file = ifcopenshell.file()
project = ifcopenshell.api.run("root.create_entity", ifc_file, ifc_class="IfcProject")
wall = ifcopenshell.api.run("root.create_entity", ifc_file, ifc_class="IfcWall")
project = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
used_guids = {project.GlobalId, wall.GlobalId}
ifcpatch.execute({"file": ifc_file, "recipe": "RegenerateGlobalIds", "arguments": [False]})
ifcpatch.execute({"file": self.file, "recipe": "RegenerateGlobalIds", "arguments": [False]})
new_guids = {project.GlobalId, wall.GlobalId}
assert not new_guids.intersection(used_guids)
def test_regenerate_guids_for_duplicates(self):
ifc_file = ifcopenshell.file()
project = ifcopenshell.api.run("root.create_entity", ifc_file, ifc_class="IfcProject")
wall1 = ifcopenshell.api.run("root.create_entity", ifc_file, ifc_class="IfcWall")
wall2 = ifcopenshell.api.run("root.create_entity", ifc_file, ifc_class="IfcWall")
project = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
wall1.GlobalId = wall2.GlobalId
used_guids = {project, wall1.GlobalId, wall2.GlobalId}
ifcpatch.execute({"file": ifc_file, "recipe": "RegenerateGlobalIds", "arguments": [True]})
ifcpatch.execute({"file": self.file, "recipe": "RegenerateGlobalIds", "arguments": [True]})
new_guids = {project, wall1.GlobalId, wall2.GlobalId}
assert len(new_guids) == 3
assert len(new_guids.intersection(used_guids)) == 2
class TestRegenerateGlobalIdsIFC2X3(test.bootstrap.IFC2X3, TestRegenerateGlobalIds):
pass