mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 11:18:18 +00:00
ifcpatch - add ifc2x3 tests and test for MergeDuplicateTypes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user