diff --git a/src/ifcopenshell-python/test/api/layer/test_assign_layer.py b/src/ifcopenshell-python/test/api/layer/test_assign_layer.py
index f2d4eca384..2e05162aad 100644
--- a/src/ifcopenshell-python/test/api/layer/test_assign_layer.py
+++ b/src/ifcopenshell-python/test/api/layer/test_assign_layer.py
@@ -37,3 +37,7 @@ class TestAssignLayer(test.bootstrap.IFC4):
ifcopenshell.api.run("layer.assign_layer", self.file, items=items[2:], layer=layer)
assert len(layer.AssignedItems) == 4
assert set(layer.AssignedItems) == set(items)
+
+
+class TestAssignLayerIFC2X3(test.bootstrap.IFC2X3, TestAssignLayer):
+ pass
diff --git a/src/ifcopenshell-python/test/api/layer/test_unassign_layer.py b/src/ifcopenshell-python/test/api/layer/test_unassign_layer.py
index 7a29896500..7332c67715 100644
--- a/src/ifcopenshell-python/test/api/layer/test_unassign_layer.py
+++ b/src/ifcopenshell-python/test/api/layer/test_unassign_layer.py
@@ -37,3 +37,7 @@ class TestUnassignLayer(test.bootstrap.IFC4):
ifcopenshell.api.run("layer.assign_layer", self.file, items=items, layer=layer)
ifcopenshell.api.run("layer.unassign_layer", self.file, items=items, layer=layer)
assert not self.file.by_type("IfcPresentationLayerAssignment")
+
+
+class TestUnassignLayerIFC2X3(test.bootstrap.IFC2X3, TestUnassignLayer):
+ pass
diff --git a/src/ifcopenshell-python/test/api/library/test_add_library.py b/src/ifcopenshell-python/test/api/library/test_add_library.py
index 731393aeaa..f964b180ac 100644
--- a/src/ifcopenshell-python/test/api/library/test_add_library.py
+++ b/src/ifcopenshell-python/test/api/library/test_add_library.py
@@ -25,3 +25,7 @@ class TestAddLibrary(test.bootstrap.IFC4):
library = ifcopenshell.api.run("library.add_library", self.file, name="Name")
assert library.is_a("IfcLibraryInformation")
assert library.Name == "Name"
+
+
+class TestAddLibraryIFC2X3(test.bootstrap.IFC2X3, TestAddLibrary):
+ pass
diff --git a/src/ifcopenshell-python/test/api/library/test_assign_reference.py b/src/ifcopenshell-python/test/api/library/test_assign_reference.py
index 550df3940f..5d00d20972 100644
--- a/src/ifcopenshell-python/test/api/library/test_assign_reference.py
+++ b/src/ifcopenshell-python/test/api/library/test_assign_reference.py
@@ -20,28 +20,6 @@ import test.bootstrap
import ifcopenshell.api
-def validate_ifc_file(ifc_file: ifcopenshell.file, use_json=True):
- import ifcopenshell
- import ifcopenshell.validate
-
- if use_json:
- logger = ifcopenshell.validate.json_logger()
- else:
- import logging
-
- logger = logging.getLogger("validate")
- logger.setLevel(logging.DEBUG)
-
- ifcopenshell.validate.validate(ifc_file, logger, express_rules=True)
- if use_json:
- if logger.statements:
- from pprint import pprint
-
- pprint(logger.statements)
- else:
- print("IFC is completely valid.")
-
-
class TestAssignReference(test.bootstrap.IFC4):
def test_assigning_a_reference(self):
reference = self.file.createIfcLibraryReference()
diff --git a/src/ifcopenshell-python/test/api/library/test_edit_library.py b/src/ifcopenshell-python/test/api/library/test_edit_library.py
index 362597d519..7d6d570666 100644
--- a/src/ifcopenshell-python/test/api/library/test_edit_library.py
+++ b/src/ifcopenshell-python/test/api/library/test_edit_library.py
@@ -17,26 +17,41 @@
# along with IfcOpenShell. If not, see .
import test.bootstrap
+import datetime
import ifcopenshell.api
+import ifcopenshell.util.date
class TestEditLibrary(test.bootstrap.IFC4):
def test_editing_a_library(self):
library = self.file.createIfcLibraryInformation()
+ dt = datetime.datetime.now()
+ attributes = {
+ "Name": "Name",
+ "Version": "Version",
+ "VersionDate": dt,
+ }
+ if self.file.schema != "IFC2X3":
+ attributes["Location"] = "Location"
+ attributes["Description"] = "Description"
+
ifcopenshell.api.run(
"library.edit_library",
self.file,
library=library,
- attributes={
- "Name": "Name",
- "Version": "Version",
- "VersionDate": "VersionDate",
- "Location": "Location",
- "Description": "Description",
- },
+ attributes=attributes,
)
assert library.Name == "Name"
assert library.Version == "Version"
- assert library.VersionDate == "VersionDate"
- assert library.Location == "Location"
- assert library.Description == "Description"
+ if self.file.schema != "IFC2X3":
+ assert library.VersionDate == ifcopenshell.util.date.datetime2ifc(dt, "IfcDateTime")
+ assert library.Location == "Location"
+ assert library.Description == "Description"
+ else:
+ info = library.VersionDate.get_info()
+ del info["id"], info["type"]
+ assert info == ifcopenshell.util.date.datetime2ifc(dt, "IfcCalendarDate")
+
+
+class TestEditLibraryIFC2X3(test.bootstrap.IFC2X3, TestEditLibrary):
+ pass
diff --git a/src/ifcopenshell-python/test/api/library/test_edit_reference.py b/src/ifcopenshell-python/test/api/library/test_edit_reference.py
index 56f169977e..338b9f4f74 100644
--- a/src/ifcopenshell-python/test/api/library/test_edit_reference.py
+++ b/src/ifcopenshell-python/test/api/library/test_edit_reference.py
@@ -23,20 +23,28 @@ import ifcopenshell.api
class TestEditReference(test.bootstrap.IFC4):
def test_editing_a_reference(self):
reference = self.file.createIfcLibraryReference()
+ attributes = {
+ "Location": "Location",
+ "Identification" if self.file.schema != "IFC2X3" else "ItemReference": "Identification",
+ "Name": "Name",
+ }
+ if self.file.schema != "IFC2X3":
+ attributes["Description"] = "Description"
+ attributes["Language"] = "Language"
ifcopenshell.api.run(
"library.edit_reference",
self.file,
reference=reference,
- attributes={
- "Location": "Location",
- "Identification": "Identification",
- "Name": "Name",
- "Description": "Description",
- "Language": "Language",
- },
+ attributes=attributes,
)
assert reference.Location == "Location"
- assert reference.Identification == "Identification"
+ # 1 IfcExternalReference Identification(>IFC2X3) / ItemReference (IFC2X3)
+ assert reference[1] == "Identification"
assert reference.Name == "Name"
- assert reference.Description == "Description"
- assert reference.Language == "Language"
+ if self.file.schema != "IFC2X3":
+ assert reference.Description == "Description"
+ assert reference.Language == "Language"
+
+
+class TestEditReferenceIFC2X3(test.bootstrap.IFC2X3, TestEditReference):
+ pass
diff --git a/src/ifcopenshell-python/test/api/library/test_remove_library.py b/src/ifcopenshell-python/test/api/library/test_remove_library.py
index 9ca623b9b6..a4743deb99 100644
--- a/src/ifcopenshell-python/test/api/library/test_remove_library.py
+++ b/src/ifcopenshell-python/test/api/library/test_remove_library.py
@@ -27,11 +27,21 @@ class TestRemoveLibrary(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcLibraryInformation")) == 0
def test_removing_a_library_and_all_references(self):
- library = self.file.createIfcLibraryInformation()
- reference1 = self.file.createIfcLibraryReference(ReferencedLibrary=library)
- reference2 = self.file.createIfcLibraryReference(ReferencedLibrary=library)
+ if self.file.schema != "IFC2X3":
+ library = self.file.createIfcLibraryInformation()
+ reference1 = self.file.createIfcLibraryReference(ReferencedLibrary=library)
+ reference2 = self.file.createIfcLibraryReference(ReferencedLibrary=library)
+ else:
+ reference1 = self.file.createIfcLibraryReference()
+ reference2 = self.file.createIfcLibraryReference()
+ library = self.file.createIfcLibraryInformation(LibraryReference=[reference1, reference2])
+
self.file.createIfcRelAssociatesLibrary(GlobalId="foo", RelatingLibrary=library)
self.file.createIfcRelAssociatesLibrary(GlobalId="bar", RelatingLibrary=reference1)
ifcopenshell.api.run("library.remove_library", self.file, library=library)
assert len(self.file.by_type("IfcLibraryReference")) == 0
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
+
+
+class TestRemoveLibraryIFC2X3(test.bootstrap.IFC2X3, TestRemoveLibrary):
+ pass
diff --git a/src/ifcopenshell-python/test/api/library/test_remove_reference.py b/src/ifcopenshell-python/test/api/library/test_remove_reference.py
index a98ed2f083..fdeca97fb5 100644
--- a/src/ifcopenshell-python/test/api/library/test_remove_reference.py
+++ b/src/ifcopenshell-python/test/api/library/test_remove_reference.py
@@ -28,3 +28,7 @@ class TestRemoveReference(test.bootstrap.IFC4):
ifcopenshell.api.run("library.remove_reference", self.file, reference=reference)
assert len(self.file.by_type("IfcLibraryReference")) == 0
assert len(self.file.by_type("IfcRelAssociatesLibrary")) == 0
+
+
+class TestRemoveReferenceIFC2X3(test.bootstrap.IFC2X3, TestRemoveReference):
+ pass
diff --git a/src/ifcopenshell-python/test/api/material/test_add_material_set.py b/src/ifcopenshell-python/test/api/material/test_add_material_set.py
index 7adb706f08..ec711d8a0e 100644
--- a/src/ifcopenshell-python/test/api/material/test_add_material_set.py
+++ b/src/ifcopenshell-python/test/api/material/test_add_material_set.py
@@ -20,12 +20,19 @@ import test.bootstrap
import ifcopenshell.api
-class TestAddMaterialSet(test.bootstrap.IFC4):
+class TestAddMaterialSetIFC2X3(test.bootstrap.IFC2X3):
def test_add_layer_set(self):
material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
assert material.LayerSetName == "Unnamed"
assert material.is_a("IfcMaterialLayerSet")
+ def test_add_list(self):
+ material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialList")
+ assert material.is_a("IfcMaterialList")
+
+
+class TestAddMaterialSetIFC4(test.bootstrap.IFC4, TestAddMaterialSetIFC2X3):
+ # entities added in IFC4
def test_add_profile_set(self):
material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialProfileSet")
assert material.Name == "Unnamed"
@@ -35,7 +42,3 @@ class TestAddMaterialSet(test.bootstrap.IFC4):
material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialConstituentSet")
assert material.Name == "Unnamed"
assert material.is_a("IfcMaterialConstituentSet")
-
- def test_add_list(self):
- material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialList")
- assert material.is_a("IfcMaterialList")
diff --git a/src/ifcopenshell-python/test/api/material/test_copy_material.py b/src/ifcopenshell-python/test/api/material/test_copy_material.py
index ce52bbd769..623814c266 100644
--- a/src/ifcopenshell-python/test/api/material/test_copy_material.py
+++ b/src/ifcopenshell-python/test/api/material/test_copy_material.py
@@ -33,19 +33,31 @@ class TestCopyMaterial(test.bootstrap.IFC4):
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
new = ifcopenshell.api.run("material.copy_material", self.file, material=material)
- assert material.AssociatedTo
- assert not new.AssociatedTo
+ assert ifcopenshell.util.element.get_elements_by_material(self.file, material)
+ assert not ifcopenshell.util.element.get_elements_by_material(self.file, new)
def test_copy_a_material_with_properties(self):
+ def get_material_props(material: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
+ if self.file.schema != "IFC2X3":
+ return material.HasProperties
+ return [i for i in self.file.get_inverse(material) if i.is_a("IfcMaterialProperties")]
+
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="Foo_Bar")
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"foo": "bar"})
new = ifcopenshell.api.run("material.copy_material", self.file, material=material)
assert new.Name == "CON01"
assert len(self.file.by_type("IfcMaterial")) == 2
- assert new.HasProperties[0] != material.HasProperties[0]
- assert new.HasProperties[0].Properties[0] != material.HasProperties[0].Properties[0]
- assert ifcopenshell.util.element.get_pset(new, "Foo_Bar", "foo") == "bar"
+ assert len(self.file.by_type("IfcMaterialProperties")) == 2
+ props_old = get_material_props(material)[0]
+ props_new = get_material_props(new)[0]
+ assert props_old != props_new
+ if self.file.schema != "IFC2X3":
+ assert props_old.Properties[0] != props_new.Properties[0]
+ assert ifcopenshell.util.element.get_pset(new, "Foo_Bar", "foo") == "bar"
+ else:
+ assert props_old.ExtendedProperties[0] != props_new.ExtendedProperties[0]
+ assert props_new.ExtendedProperties[0].NominalValue.wrappedValue == "bar"
def test_copy_a_material_with_a_style_representation(self):
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
@@ -59,3 +71,6 @@ class TestCopyMaterial(test.bootstrap.IFC4):
assert new.HasRepresentation[0] != material.HasRepresentation[0]
assert new.HasRepresentation[0].Representations[0] != material.HasRepresentation[0].Representations[0]
assert new.HasRepresentation[0].Representations[0].ContextOfItems == context
+
+class TestCopyMaterialIFC2X3(test.bootstrap.IFC2X3, TestCopyMaterial):
+ pass
diff --git a/src/ifcopenshell-python/test/api/material/test_remove_material.py b/src/ifcopenshell-python/test/api/material/test_remove_material.py
index 0670c09bbb..e5690dcfd5 100644
--- a/src/ifcopenshell-python/test/api/material/test_remove_material.py
+++ b/src/ifcopenshell-python/test/api/material/test_remove_material.py
@@ -20,7 +20,7 @@ import test.bootstrap
import ifcopenshell.api
-class TestRemoveMaterial(test.bootstrap.IFC4):
+class TestRemoveMaterialIFC2X3(test.bootstrap.IFC2X3):
def test_removing_material(self):
material = ifcopenshell.api.run("material.add_material", self.file)
ifcopenshell.api.run("material.remove_material", self.file, material=material)
@@ -37,9 +37,7 @@ class TestRemoveMaterial(test.bootstrap.IFC4):
def test_removing_material_in_layer(self):
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run(
- "material.add_material_set", self.file, set_type="IfcMaterialLayerSet"
- )
+ material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
assert len(self.file.by_type("IfcMaterialLayerSet")[0].MaterialLayers) == 1
@@ -48,40 +46,10 @@ class TestRemoveMaterial(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
assert len(self.file.by_type("IfcMaterialLayerSet")[0].MaterialLayers) == 0
- def test_removing_material_in_profile(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run(
- "material.add_material_set", self.file, set_type="IfcMaterialProfileSet"
- )
- ifcopenshell.api.run("material.add_profile", self.file, profile_set=material_set, material=material)
- ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
- assert len(self.file.by_type("IfcMaterialProfileSet")[0].MaterialProfiles) == 1
- ifcopenshell.api.run("material.remove_material", self.file, material=material)
- assert len(self.file.by_type("IfcMaterial")) == 0
- assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
- assert len(self.file.by_type("IfcMaterialProfileSet")[0].MaterialProfiles) == 0
-
- def test_removing_material_in_constituent(self):
- wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
- material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run(
- "material.add_material_set", self.file, set_type="IfcMaterialConstituentSet"
- )
- ifcopenshell.api.run("material.add_constituent", self.file, constituent_set=material_set, material=material)
- ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
- assert len(self.file.by_type("IfcMaterialConstituentSet")[0].MaterialConstituents) == 1
- ifcopenshell.api.run("material.remove_material", self.file, material=material)
- assert len(self.file.by_type("IfcMaterial")) == 0
- assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
- assert self.file.by_type("IfcMaterialConstituentSet")[0].MaterialConstituents is None
-
def test_removing_material_in_list(self):
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
material = ifcopenshell.api.run("material.add_material", self.file)
- material_set = ifcopenshell.api.run(
- "material.add_material_set", self.file, set_type="IfcMaterialList"
- )
+ material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialList")
ifcopenshell.api.run("material.add_list_item", self.file, material_list=material_set, material=material)
ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
assert len(self.file.by_type("IfcMaterialList")[0].Materials) == 1
@@ -108,10 +76,44 @@ class TestRemoveMaterial(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcSurfaceStyle")) == 1
def test_removing_a_material_with_properties(self):
+ def get_material_props(material: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
+ if self.file.schema != "IFC2X3":
+ return material.HasProperties
+ return [i for i in self.file.get_inverse(material) if i.is_a("IfcMaterialProperties")]
+
material = ifcopenshell.api.run("material.add_material", self.file)
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="Foo_Bar")
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
- assert material.HasProperties
+ assert get_material_props(material)
ifcopenshell.api.run("material.remove_material", self.file, material=material)
assert len(self.file.by_type("IfcMaterialProperties")) == 0
assert len(self.file.by_type("IfcPropertySingleValue")) == 0
+
+
+class TestRemoveMaterialIFC4(test.bootstrap.IFC4, TestRemoveMaterialIFC2X3):
+ # IfcMaterialProfileSet added in IFC4
+ def test_removing_material_in_profile(self):
+ wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.run("material.add_material", self.file)
+ material_set = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialProfileSet")
+ ifcopenshell.api.run("material.add_profile", self.file, profile_set=material_set, material=material)
+ ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
+ assert len(self.file.by_type("IfcMaterialProfileSet")[0].MaterialProfiles) == 1
+ ifcopenshell.api.run("material.remove_material", self.file, material=material)
+ assert len(self.file.by_type("IfcMaterial")) == 0
+ assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
+ assert len(self.file.by_type("IfcMaterialProfileSet")[0].MaterialProfiles) == 0
+
+ def test_removing_material_in_constituent(self):
+ wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
+ material = ifcopenshell.api.run("material.add_material", self.file)
+ material_set = ifcopenshell.api.run(
+ "material.add_material_set", self.file, set_type="IfcMaterialConstituentSet"
+ )
+ ifcopenshell.api.run("material.add_constituent", self.file, constituent_set=material_set, material=material)
+ ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
+ assert len(self.file.by_type("IfcMaterialConstituentSet")[0].MaterialConstituents) == 1
+ ifcopenshell.api.run("material.remove_material", self.file, material=material)
+ assert len(self.file.by_type("IfcMaterial")) == 0
+ assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
+ assert self.file.by_type("IfcMaterialConstituentSet")[0].MaterialConstituents is None
diff --git a/src/ifcopenshell-python/test/api/material/test_remove_material_set.py b/src/ifcopenshell-python/test/api/material/test_remove_material_set.py
index 7554225efe..0ec549d67a 100644
--- a/src/ifcopenshell-python/test/api/material/test_remove_material_set.py
+++ b/src/ifcopenshell-python/test/api/material/test_remove_material_set.py
@@ -20,7 +20,7 @@ import test.bootstrap
import ifcopenshell.api
-class TestRemoveMaterialSet(test.bootstrap.IFC4):
+class TestRemoveMaterialSetIFC2X3(test.bootstrap.IFC2X3):
def test_removing_material_set(self):
material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
ifcopenshell.api.run("material.remove_material_set", self.file, material=material)
@@ -43,6 +43,9 @@ class TestRemoveMaterialSet(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcMaterialLayer")) == 0
assert len(self.file.by_type("IfcMaterial")) == 1
+
+class TestRemoveMaterialSetIFC4(test.bootstrap.IFC4, TestRemoveMaterialSetIFC2X3):
+ # IFC2X3 doesn't support adding a pset to IfcMaterialLayerSet
def test_removing_a_material_set_with_properties(self):
material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=material, name="Foo_Bar")
diff --git a/src/ifcopenshell-python/test/api/owner/test_add_actor.py b/src/ifcopenshell-python/test/api/owner/test_add_actor.py
index 0d9af85100..82b43f9a96 100644
--- a/src/ifcopenshell-python/test/api/owner/test_add_actor.py
+++ b/src/ifcopenshell-python/test/api/owner/test_add_actor.py
@@ -32,3 +32,7 @@ class TestAddActor(test.bootstrap.IFC4):
actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcOccupant", actor=person)
assert actor.is_a() == "IfcOccupant"
assert actor.TheActor == person
+
+
+class TestAddActorIFC2X3(test.bootstrap.IFC2X3, TestAddActor):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_add_address.py b/src/ifcopenshell-python/test/api/owner/test_add_address.py
index 452d0fea5f..31c18f6be4 100644
--- a/src/ifcopenshell-python/test/api/owner/test_add_address.py
+++ b/src/ifcopenshell-python/test/api/owner/test_add_address.py
@@ -48,3 +48,7 @@ class TestAddAddress(test.bootstrap.IFC4):
assert postal.Purpose == telecom.Purpose == "OFFICE"
assert postal in organisation.Addresses
assert telecom in organisation.Addresses
+
+
+class TestAddAddressIFC2X3(test.bootstrap.IFC2X3, TestAddAddress):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_add_application.py b/src/ifcopenshell-python/test/api/owner/test_add_application.py
index 3c28bb3e2d..182f4feea9 100644
--- a/src/ifcopenshell-python/test/api/owner/test_add_application.py
+++ b/src/ifcopenshell-python/test/api/owner/test_add_application.py
@@ -28,7 +28,8 @@ class TestAddApplication(test.bootstrap.IFC4):
assert application.ApplicationFullName == "IfcOpenShell"
assert application.ApplicationIdentifier == "IfcOpenShell"
assert developer.is_a("IfcOrganization")
- assert developer.Identification == "IfcOpenShell"
+ # 0 IfcOrganization Identification(>IFC2X3) / Id (IFC2X3)
+ assert developer[0] == "IfcOpenShell"
assert developer.Name == "IfcOpenShell"
assert (
developer.Description
@@ -40,3 +41,7 @@ class TestAddApplication(test.bootstrap.IFC4):
assert developer.Addresses[0].Purpose == "USERDEFINED"
assert developer.Addresses[0].UserDefinedPurpose == "WEBPAGE"
assert developer.Addresses[0].WWWHomePageURL == "https://ifcopenshell.org"
+
+
+class TestAddApplicationIFC2X3(test.bootstrap.IFC2X3, TestAddApplication):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_add_organisation.py b/src/ifcopenshell-python/test/api/owner/test_add_organisation.py
index e6fffab2ae..f7aad1c0a0 100644
--- a/src/ifcopenshell-python/test/api/owner/test_add_organisation.py
+++ b/src/ifcopenshell-python/test/api/owner/test_add_organisation.py
@@ -23,5 +23,10 @@ import ifcopenshell.api
class TestAddOrganisation(test.bootstrap.IFC4):
def test_adding_an_organisation(self):
org = ifcopenshell.api.run("owner.add_organisation", self.file, identification="Id", name="Name")
- assert org.Identification == "Id"
+ # 0 IfcOrganization Identification(>IFC2X3) / Id (IFC2X3)
+ assert org[0] == "Id"
assert org.Name == "Name"
+
+
+class TestAddOrganisationIFC2X3(test.bootstrap.IFC2X3, TestAddOrganisation):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_add_person.py b/src/ifcopenshell-python/test/api/owner/test_add_person.py
index 5d3a272119..6aed44c8db 100644
--- a/src/ifcopenshell-python/test/api/owner/test_add_person.py
+++ b/src/ifcopenshell-python/test/api/owner/test_add_person.py
@@ -29,6 +29,11 @@ class TestAddPerson(test.bootstrap.IFC4):
family_name="FamilyName",
given_name="GivenName",
)
- assert person.Identification == "Identification"
+ # 0 IfcPerson Identification(>IFC2X3) / Id (IFC2X3)
+ assert person[0] == "Identification"
assert person.FamilyName == "FamilyName"
assert person.GivenName == "GivenName"
+
+
+class TestAddPersonIFC2X3(test.bootstrap.IFC2X3, TestAddPerson):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_add_person_and_organisation.py b/src/ifcopenshell-python/test/api/owner/test_add_person_and_organisation.py
index a82d99691e..079d162433 100644
--- a/src/ifcopenshell-python/test/api/owner/test_add_person_and_organisation.py
+++ b/src/ifcopenshell-python/test/api/owner/test_add_person_and_organisation.py
@@ -27,3 +27,7 @@ class TestAddPersonAndOrganisation(test.bootstrap.IFC4):
person_and_organisation = ifcopenshell.api.run(
"owner.add_person_and_organisation", self.file, person=person, organisation=organisation
)
+
+
+class TestAddPersonAndOrganisationIFC2X3(test.bootstrap.IFC2X3, TestAddPersonAndOrganisation):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_add_role.py b/src/ifcopenshell-python/test/api/owner/test_add_role.py
index 393ff5964d..08351996b6 100644
--- a/src/ifcopenshell-python/test/api/owner/test_add_role.py
+++ b/src/ifcopenshell-python/test/api/owner/test_add_role.py
@@ -34,3 +34,7 @@ class TestAddRole(test.bootstrap.IFC4):
assert role.is_a("IfcActorRole")
assert role.Role == "ARCHITECT"
assert organisation.Roles == (role,)
+
+
+class TestAddRoleIFC2X3(test.bootstrap.IFC2X3, TestAddRole):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_assign_actor.py b/src/ifcopenshell-python/test/api/owner/test_assign_actor.py
index 720cf1492b..bfd846ecfd 100644
--- a/src/ifcopenshell-python/test/api/owner/test_assign_actor.py
+++ b/src/ifcopenshell-python/test/api/owner/test_assign_actor.py
@@ -20,7 +20,7 @@ import test.bootstrap
import ifcopenshell.api
-class TestAssignProduct(test.bootstrap.IFC4):
+class TestAssignActor(test.bootstrap.IFC4):
def test_assigning_an_actor(self):
wall = self.file.createIfcWall()
wall2 = self.file.createIfcWall()
@@ -36,3 +36,7 @@ class TestAssignProduct(test.bootstrap.IFC4):
ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
assert actor.IsActingUpon[0].RelatedObjects == (wall,)
+
+
+class TestAssignActorIFC2X3(test.bootstrap.IFC2X3, TestAssignActor):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_create_owner_history.py b/src/ifcopenshell-python/test/api/owner/test_create_owner_history.py
index b57f08a6af..a9a60472bb 100644
--- a/src/ifcopenshell-python/test/api/owner/test_create_owner_history.py
+++ b/src/ifcopenshell-python/test/api/owner/test_create_owner_history.py
@@ -17,25 +17,36 @@
# along with IfcOpenShell. If not, see .
import time
+import pytest
import test.bootstrap
import ifcopenshell.api
+import ifcopenshell.api.owner.settings
class TestCreateOwnerHistory(test.bootstrap.IFC4):
def test_creating_nothing_if_no_user_or_application_is_available(self):
- history = ifcopenshell.api.run("owner.create_owner_history", self.file)
- assert history is None
+ if self.file.schema != "IFC2X3":
+ history = ifcopenshell.api.run("owner.create_owner_history", self.file)
+ assert history is None
+ else:
+ ifcopenshell.api.owner.settings.factory_reset()
+ # create new file as bootstrap is creating users in ifc2x3 by default
+ file = ifcopenshell.file(schema="IFC2X3")
+ with pytest.raises(Exception) as e:
+ ifcopenshell.api.run("owner.create_owner_history", file)
+ assert "Please create a user to continue" in str(e.value)
+ ifcopenshell.api.owner.settings.restore()
def test_creating_a_history_using_a_specified_user_and_application(self):
- old_get_user = ifcopenshell.api.owner.settings.get_user
- old_get_application = ifcopenshell.api.owner.settings.get_application
+ ifcopenshell.api.owner.settings.factory_reset()
+
user = self.file.createIfcPersonAndOrganization()
application = self.file.createIfcApplication()
ifcopenshell.api.owner.settings.get_user = lambda x: user
ifcopenshell.api.owner.settings.get_application = lambda x: application
history = ifcopenshell.api.run("owner.create_owner_history", self.file)
- ifcopenshell.api.owner.settings.get_user = old_get_user
- ifcopenshell.api.owner.settings.get_application = old_get_application
+ ifcopenshell.api.owner.settings.restore()
+
assert history.is_a("IfcOwnerHistory")
assert history.OwningUser == user
assert history.OwningApplication == application
@@ -45,3 +56,7 @@ class TestCreateOwnerHistory(test.bootstrap.IFC4):
assert history.LastModifyingUser == user
assert history.LastModifyingApplication == application
assert abs(time.time() - history.CreationDate) < 5
+
+
+class TestCreateOwnerHistoryIFC2X3(test.bootstrap.IFC2X3, TestCreateOwnerHistory):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_edit_actor.py b/src/ifcopenshell-python/test/api/owner/test_edit_actor.py
index 94227a055e..de30e7ba29 100644
--- a/src/ifcopenshell-python/test/api/owner/test_edit_actor.py
+++ b/src/ifcopenshell-python/test/api/owner/test_edit_actor.py
@@ -52,3 +52,7 @@ class TestEditActor(test.bootstrap.IFC4):
assert actor.Description == "Description"
assert actor.ObjectType == "ObjectType"
assert actor.PredefinedType == "TENANT"
+
+
+class TestEditActorIFC2X3(test.bootstrap.IFC2X3, TestEditActor):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_edit_address.py b/src/ifcopenshell-python/test/api/owner/test_edit_address.py
index d56e9860f6..c7a69db019 100644
--- a/src/ifcopenshell-python/test/api/owner/test_edit_address.py
+++ b/src/ifcopenshell-python/test/api/owner/test_edit_address.py
@@ -53,21 +53,24 @@ class TestEditAddress(test.bootstrap.IFC4):
def test_editing_a_telecom_address(self):
address = self.file.createIfcTelecomAddress()
+ attributes = {
+ "Purpose": "OFFICE",
+ "Description": "Description",
+ "UserDefinedPurpose": "UserDefinedPurpose",
+ "TelephoneNumbers": ["Telephone", "Numbers"],
+ "FacsimileNumbers": ["Facsimile", "Numbers"],
+ "PagerNumber": "PagerNumber",
+ "ElectronicMailAddresses": ["Electronic", "Mail", "Addresses"],
+ "WWWHomePageURL": "WWWHomePageURL",
+ }
+ if self.file.schema != "IFC2X3":
+ attributes["MessagingIDs"] = ["Messaging", "IDs"]
+
ifcopenshell.api.run(
"owner.edit_address",
self.file,
address=address,
- attributes={
- "Purpose": "OFFICE",
- "Description": "Description",
- "UserDefinedPurpose": "UserDefinedPurpose",
- "TelephoneNumbers": ["Telephone", "Numbers"],
- "FacsimileNumbers": ["Facsimile", "Numbers"],
- "PagerNumber": "PagerNumber",
- "ElectronicMailAddresses": ["Electronic", "Mail", "Addresses"],
- "WWWHomePageURL": "WWWHomePageURL",
- "MessagingIDs": ["Messaging", "IDs"],
- },
+ attributes=attributes,
)
assert address.Purpose == "OFFICE"
assert address.Description == "Description"
@@ -77,4 +80,9 @@ class TestEditAddress(test.bootstrap.IFC4):
assert address.PagerNumber == "PagerNumber"
assert address.ElectronicMailAddresses == ("Electronic", "Mail", "Addresses")
assert address.WWWHomePageURL == "WWWHomePageURL"
- assert address.MessagingIDs == ("Messaging", "IDs")
+ if self.file.schema != "IFC2X3":
+ assert address.MessagingIDs == ("Messaging", "IDs")
+
+
+class TestEditAddressIFC2X3(test.bootstrap.IFC2X3, TestEditAddress):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_edit_organisation.py b/src/ifcopenshell-python/test/api/owner/test_edit_organisation.py
index a7a5e41a3c..8ec224dd25 100644
--- a/src/ifcopenshell-python/test/api/owner/test_edit_organisation.py
+++ b/src/ifcopenshell-python/test/api/owner/test_edit_organisation.py
@@ -28,11 +28,16 @@ class TestEditOrganisation(test.bootstrap.IFC4):
self.file,
organisation=organisation,
attributes={
- "Identification": "Identification",
+ "Identification" if self.file.schema != "IFC2X3" else "Id": "Identification",
"Name": "Name",
"Description": "Description",
},
)
- assert organisation.Identification == "Identification"
+ # 0 IfcOrganization Identification(>IFC2X3) / Id (IFC2X3)
+ assert organisation[0] == "Identification"
assert organisation.Name == "Name"
assert organisation.Description == "Description"
+
+
+class TestEditOrganisationIFC2X3(test.bootstrap.IFC2X3, TestEditOrganisation):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_edit_person.py b/src/ifcopenshell-python/test/api/owner/test_edit_person.py
index ef35b5d173..0d5d8a2c97 100644
--- a/src/ifcopenshell-python/test/api/owner/test_edit_person.py
+++ b/src/ifcopenshell-python/test/api/owner/test_edit_person.py
@@ -28,7 +28,7 @@ class TestEditPerson(test.bootstrap.IFC4):
self.file,
person=person,
attributes={
- "Identification": "Identification",
+ "Identification" if self.file.schema != "IFC2X3" else "Id": "Identification",
"FamilyName": "FamilyName",
"GivenName": "GivenName",
"MiddleNames": ["Middle", "Names"],
@@ -36,9 +36,14 @@ class TestEditPerson(test.bootstrap.IFC4):
"SuffixTitles": ["Suffix", "Titles"],
},
)
- assert person.Identification == "Identification"
+ # 0 IfcPerson Identification(>IFC2X3) / Id (IFC2X3)
+ assert person[0] == "Identification"
assert person.FamilyName == "FamilyName"
assert person.GivenName == "GivenName"
assert person.MiddleNames == ("Middle", "Names")
assert person.PrefixTitles == ("Prefix", "Titles")
assert person.SuffixTitles == ("Suffix", "Titles")
+
+
+class TestEditPersonIFC2X3(test.bootstrap.IFC2X3, TestEditPerson):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_edit_role.py b/src/ifcopenshell-python/test/api/owner/test_edit_role.py
index f47b1601e8..693ff29c5b 100644
--- a/src/ifcopenshell-python/test/api/owner/test_edit_role.py
+++ b/src/ifcopenshell-python/test/api/owner/test_edit_role.py
@@ -32,3 +32,7 @@ class TestEditRole(test.bootstrap.IFC4):
assert role.Role == "ARCHITECT"
assert role.UserDefinedRole == "UserDefinedRole"
assert role.Description == "Description"
+
+
+class TestEditRoleIFC2X3(test.bootstrap.IFC2X3, TestEditRole):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_remove_actor.py b/src/ifcopenshell-python/test/api/owner/test_remove_actor.py
index 7a068d3735..b3a387f2e6 100644
--- a/src/ifcopenshell-python/test/api/owner/test_remove_actor.py
+++ b/src/ifcopenshell-python/test/api/owner/test_remove_actor.py
@@ -26,3 +26,7 @@ class TestRemoveActor(test.bootstrap.IFC4):
actor = ifcopenshell.api.run("owner.add_actor", self.file, ifc_class="IfcActor", actor=person)
ifcopenshell.api.run("owner.remove_actor", self.file, actor=actor)
assert len(self.file.by_type("IfcActor")) == 0
+
+
+class TestRemoveActorIFC2X3(test.bootstrap.IFC2X3, TestRemoveActor):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_remove_address.py b/src/ifcopenshell-python/test/api/owner/test_remove_address.py
index f8f61a888b..d0a26a10aa 100644
--- a/src/ifcopenshell-python/test/api/owner/test_remove_address.py
+++ b/src/ifcopenshell-python/test/api/owner/test_remove_address.py
@@ -41,3 +41,7 @@ class TestRemoveAddress(test.bootstrap.IFC4):
person.Addresses = [address]
ifcopenshell.api.run("owner.remove_address", self.file, address=address)
assert person.Addresses is None
+
+
+class TestRemoveAddressIFC2X3(test.bootstrap.IFC2X3, TestRemoveAddress):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_remove_organisation.py b/src/ifcopenshell-python/test/api/owner/test_remove_organisation.py
index f669dc6814..232b74795c 100644
--- a/src/ifcopenshell-python/test/api/owner/test_remove_organisation.py
+++ b/src/ifcopenshell-python/test/api/owner/test_remove_organisation.py
@@ -21,7 +21,7 @@ import ifcopenshell.api
import ifcopenshell.guid
-class TestRemoveOrganisation(test.bootstrap.IFC4):
+class TestRemoveOrganisationIFC2X3(test.bootstrap.IFC2X3):
def test_removing_a_organisation(self):
organisation = self.file.createIfcOrganization()
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
@@ -82,26 +82,29 @@ class TestRemoveOrganisation(test.bootstrap.IFC4):
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
assert document_information.Editors is None
- def test_deleting_resource_approval_relationships(self):
- organisation = self.file.createIfcOrganization()
- self.file.createIfcResourceApprovalRelationship(RelatedResourceObjects=[organisation])
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
- assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
-
- def test_deleting_resource_constraint_relationships(self):
- organisation = self.file.createIfcOrganization()
- self.file.createIfcResourceConstraintRelationship(RelatedResourceObjects=[organisation])
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
- assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
-
- def test_deleting_external_reference_relationships(self):
- organisation = self.file.createIfcOrganization()
- self.file.createIfcExternalReferenceRelationship(RelatedResourceObjects=[organisation])
- ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
- assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
-
def test_deleting_an_application(self):
organisation = self.file.createIfcOrganization()
self.file.createIfcApplication(ApplicationDeveloper=organisation)
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
assert len(self.file.by_type("IfcApplication")) == 0
+
+
+class TestRemoveOrganisationIFC4(test.bootstrap.IFC4, TestRemoveOrganisationIFC2X3):
+ # IfcResourceLevelRelationships were added in IFC4
+ def test_deleting_resource_approval_relationships(self):
+ organisation = self.file.create_entity("IfcOrganization")
+ self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[organisation])
+ ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
+
+ def test_deleting_resource_constraint_relationships(self):
+ organisation = self.file.create_entity("IfcOrganization")
+ self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[organisation])
+ ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
+
+ def test_deleting_external_reference_relationships(self):
+ organisation = self.file.create_entity("IfcOrganization")
+ self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[organisation])
+ ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
+ assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
diff --git a/src/ifcopenshell-python/test/api/owner/test_remove_person.py b/src/ifcopenshell-python/test/api/owner/test_remove_person.py
index 76d641a85f..0f4f6d55da 100644
--- a/src/ifcopenshell-python/test/api/owner/test_remove_person.py
+++ b/src/ifcopenshell-python/test/api/owner/test_remove_person.py
@@ -16,12 +16,13 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see .
+import pytest
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.guid
-class TestRemovePerson(test.bootstrap.IFC4):
+class TestRemovePersonIFC2X3(test.bootstrap.IFC2X3):
def test_removing_a_person(self):
person = self.file.createIfcPerson()
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
@@ -87,20 +88,23 @@ class TestRemovePerson(test.bootstrap.IFC4):
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
assert document_information.Editors is None
+
+class TestRemovePersonIFC4(test.bootstrap.IFC4, TestRemovePersonIFC2X3):
+ # IfcResourceLevelRelationships were added in IFC4
def test_deleting_resource_approval_relationships(self):
- person = self.file.createIfcPerson()
- self.file.createIfcResourceApprovalRelationship(RelatedResourceObjects=[person])
+ person = self.file.create_entity("IfcPerson")
+ self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[person])
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
def test_deleting_resource_constraint_relationships(self):
- person = self.file.createIfcPerson()
- self.file.createIfcResourceConstraintRelationship(RelatedResourceObjects=[person])
+ person = self.file.create_entity("IfcPerson")
+ self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[person])
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
def test_deleting_external_reference_relationships(self):
- person = self.file.createIfcPerson()
- self.file.createIfcExternalReferenceRelationship(RelatedResourceObjects=[person])
+ person = self.file.create_entity("IfcPerson")
+ self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[person])
ifcopenshell.api.run("owner.remove_person", self.file, person=person)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
diff --git a/src/ifcopenshell-python/test/api/owner/test_remove_person_and_organisation.py b/src/ifcopenshell-python/test/api/owner/test_remove_person_and_organisation.py
index 0c2c8b53f8..4b0956b126 100644
--- a/src/ifcopenshell-python/test/api/owner/test_remove_person_and_organisation.py
+++ b/src/ifcopenshell-python/test/api/owner/test_remove_person_and_organisation.py
@@ -21,7 +21,7 @@ import ifcopenshell.api
import ifcopenshell.guid
-class TestRemovePersonAndOrganisation(test.bootstrap.IFC4):
+class TestRemovePersonAndOrganisationIFC2X3(test.bootstrap.IFC2X3):
def test_removing(self):
user = self.file.createIfcPersonAndOrganization()
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
@@ -39,26 +39,29 @@ class TestRemovePersonAndOrganisation(test.bootstrap.IFC4):
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
assert document_information.Editors is None
- def test_deleting_resource_approval_relationships(self):
- user = self.file.createIfcPersonAndOrganization()
- self.file.createIfcResourceApprovalRelationship(RelatedResourceObjects=[user])
- ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
- assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
-
- def test_deleting_resource_constraint_relationships(self):
- user = self.file.createIfcPersonAndOrganization()
- self.file.createIfcResourceConstraintRelationship(RelatedResourceObjects=[user])
- ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
- assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
-
- def test_deleting_external_reference_relationships(self):
- user = self.file.createIfcPersonAndOrganization()
- self.file.createIfcExternalReferenceRelationship(RelatedResourceObjects=[user])
- ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
- assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
-
def test_deleting_owner_history(self):
user = self.file.createIfcPersonAndOrganization()
self.file.createIfcOwnerHistory(OwningUser=user)
ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
assert len(self.file.by_type("IfcOwnerHistory")) == 0
+
+
+class TestRemovePersonAndOrganisationIFC4(test.bootstrap.IFC4, TestRemovePersonAndOrganisationIFC2X3):
+ # IfcResourceLevelRelationships were added in IFC4
+ def test_deleting_resource_approval_relationships(self):
+ user = self.file.create_entity("IfcPersonAndOrganization")
+ self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[user])
+ ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
+ assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
+
+ def test_deleting_resource_constraint_relationships(self):
+ user = self.file.create_entity("IfcPersonAndOrganization")
+ self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[user])
+ ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
+ assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
+
+ def test_deleting_external_reference_relationships(self):
+ user = self.file.create_entity("IfcPersonAndOrganization")
+ self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[user])
+ ifcopenshell.api.run("owner.remove_person_and_organisation", self.file, person_and_organisation=user)
+ assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
diff --git a/src/ifcopenshell-python/test/api/owner/test_remove_role.py b/src/ifcopenshell-python/test/api/owner/test_remove_role.py
index 9aae7324f2..110adbd9bf 100644
--- a/src/ifcopenshell-python/test/api/owner/test_remove_role.py
+++ b/src/ifcopenshell-python/test/api/owner/test_remove_role.py
@@ -20,7 +20,7 @@ import test.bootstrap
import ifcopenshell.api
-class TestRemoveRole(test.bootstrap.IFC4):
+class TestRemoveRoleIFC2X3(test.bootstrap.IFC2X3):
def test_removing_a_role(self):
role = self.file.createIfcActorRole()
ifcopenshell.api.run("owner.remove_role", self.file, role=role)
@@ -47,20 +47,22 @@ class TestRemoveRole(test.bootstrap.IFC4):
ifcopenshell.api.run("owner.remove_role", self.file, role=role)
assert person_and_organisation.Roles is None
+
+class TestRemoveRoleIFC4(test.bootstrap.IFC4, TestRemoveRoleIFC2X3):
def test_deleting_resource_approval_relationships(self):
- organisation = self.file.createIfcOrganization()
- self.file.createIfcResourceApprovalRelationship(RelatedResourceObjects=[organisation])
+ organisation = self.file.create_entity("IfcOrganization")
+ self.file.create_entity("IfcResourceApprovalRelationship", RelatedResourceObjects=[organisation])
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
assert len(self.file.by_type("IfcResourceApprovalRelationship")) == 0
def test_deleting_resource_constraint_relationships(self):
- organisation = self.file.createIfcOrganization()
- self.file.createIfcResourceConstraintRelationship(RelatedResourceObjects=[organisation])
+ organisation = self.file.create_entity("IfcOrganization")
+ self.file.create_entity("IfcResourceConstraintRelationship", RelatedResourceObjects=[organisation])
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
assert len(self.file.by_type("IfcResourceConstraintRelationship")) == 0
def test_deleting_external_reference_relationships(self):
- organisation = self.file.createIfcOrganization()
- self.file.createIfcExternalReferenceRelationship(RelatedResourceObjects=[organisation])
+ organisation = self.file.create_entity("IfcOrganization")
+ self.file.create_entity("IfcExternalReferenceRelationship", RelatedResourceObjects=[organisation])
ifcopenshell.api.run("owner.remove_organisation", self.file, organisation=organisation)
assert len(self.file.by_type("IfcExternalReferenceRelationship")) == 0
diff --git a/src/ifcopenshell-python/test/api/owner/test_unassign_actor.py b/src/ifcopenshell-python/test/api/owner/test_unassign_actor.py
index c7e4e7c220..7f0b6f378f 100644
--- a/src/ifcopenshell-python/test/api/owner/test_unassign_actor.py
+++ b/src/ifcopenshell-python/test/api/owner/test_unassign_actor.py
@@ -27,3 +27,7 @@ class TestUnassignActor(test.bootstrap.IFC4):
ifcopenshell.api.run("owner.assign_actor", self.file, relating_actor=actor, related_object=wall)
ifcopenshell.api.run("owner.unassign_actor", self.file, relating_actor=actor, related_object=wall)
assert len(self.file.by_type("IfcRelAssignsToActor")) == 0
+
+
+class TestUnassignActorIFC2X3(test.bootstrap.IFC2X3, TestUnassignActor):
+ pass
diff --git a/src/ifcopenshell-python/test/api/owner/test_update_owner_history.py b/src/ifcopenshell-python/test/api/owner/test_update_owner_history.py
index 3d2fa4aa83..107fb5a0ab 100644
--- a/src/ifcopenshell-python/test/api/owner/test_update_owner_history.py
+++ b/src/ifcopenshell-python/test/api/owner/test_update_owner_history.py
@@ -96,3 +96,7 @@ class TestUpdateOwnerHistory(test.bootstrap.IFC4):
def test_doing_nothing_if_no_history_can_be_updated(self):
person = self.file.createIfcPerson()
assert ifcopenshell.api.run("owner.update_owner_history", self.file, element=person) == None
+
+
+class TestUpdateOwnerHistoryIFC2X3(test.bootstrap.IFC2X3, TestUpdateOwnerHistory):
+ pass
diff --git a/src/ifcopenshell-python/test/api/project/test_append_asset.py b/src/ifcopenshell-python/test/api/project/test_append_asset.py
index 84444218d6..552c865fe4 100644
--- a/src/ifcopenshell-python/test/api/project/test_append_asset.py
+++ b/src/ifcopenshell-python/test/api/project/test_append_asset.py
@@ -21,9 +21,9 @@ import ifcopenshell.api
import ifcopenshell.util.element
-class TestAppendAsset(test.bootstrap.IFC4):
+class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
def test_do_not_append_twice(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
material = ifcopenshell.api.run("material.add_material", library, name="Material")
schedule = ifcopenshell.api.run("cost.add_cost_schedule", library, name="Schedule")
@@ -40,13 +40,13 @@ class TestAppendAsset(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcWallType")) == 1
def test_append_a_type_product(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
assert len(self.file.by_type("IfcWallType")) == 1
def test_reuse_an_existing_context_if_it_was_added_from_library_previously(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
project = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
lib_context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
@@ -66,7 +66,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
assert context.WorldCoordinateSystem
def test_append_a_single_type_product_even_though_an_inverse_material_relationship_is_shared(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
element2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
material = ifcopenshell.api.run("material.add_material", library, name="Material")
@@ -76,7 +76,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcWallType")) == 1
def test_append_a_type_product_with_its_materials(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
material = ifcopenshell.api.run("material.add_material", library, name="Material")
ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
@@ -84,7 +84,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
assert self.file.by_type("IfcWallType")[0].HasAssociations[0].RelatingMaterial.Name == "Material"
def test_append_a_type_product_where_its_inverse_material_relationship_refers_to_products_not_in_scope(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
element_type2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
@@ -102,34 +102,11 @@ class TestAppendAsset(test.bootstrap.IFC4):
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element_type2)
assert set(self.file.by_type("IfcWall")) == set()
- def test_append_two_type_products_sharing_the_same_material_with_properties(self):
- library = ifcopenshell.api.run("project.create_file")
- element1 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- element2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- material = ifcopenshell.api.run("material.add_material", library, name="Material")
-
- pset = ifcopenshell.api.run("pset.add_pset", library, product=material, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", library, pset=pset, properties={"Foo": "Bar"})
-
- ifcopenshell.api.run("material.assign_material", library, products=[element1], material=material)
- ifcopenshell.api.run("material.assign_material", library, products=[element2], material=material)
- new1 = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element1)
- new2 = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element2)
-
- assert len(self.file.by_type("IfcMaterialProperties")) == 1
- material = self.file.by_type("IfcMaterial")[0]
- assert ifcopenshell.util.element.get_material(new1) == material
- assert ifcopenshell.util.element.get_material(new2) == material
- assert ifcopenshell.util.element.get_psets(material)["Foo_Bar"]["Foo"] == "Bar"
-
def test_append_two_type_products_sharing_the_same_material_indirectly_via_a_material_set(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element1 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
element2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
-
material = ifcopenshell.api.run("material.add_material", library, name="Material")
- pset = ifcopenshell.api.run("pset.add_pset", library, product=material, name="Foo_Bar")
- ifcopenshell.api.run("pset.edit_pset", library, pset=pset, properties={"Foo": "Bar"})
layer_set1 = ifcopenshell.api.run("material.add_material_set", library, set_type="IfcMaterialLayerSet")
ifcopenshell.api.run("material.add_layer", library, layer_set=layer_set1, material=material)
@@ -145,16 +122,14 @@ class TestAppendAsset(test.bootstrap.IFC4):
new1 = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element1)
new2 = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element2)
- assert len(self.file.by_type("IfcMaterialProperties")) == 1
material = self.file.by_type("IfcMaterial")[0]
assert ifcopenshell.util.element.get_material(new1).MaterialLayers[0].Material == material
assert ifcopenshell.util.element.get_material(new1).MaterialLayers[1].Material == material
assert ifcopenshell.util.element.get_material(new2).MaterialLayers[0].Material == material
assert ifcopenshell.util.element.get_material(new2).MaterialLayers[1].Material == material
- assert ifcopenshell.util.element.get_psets(material)["Foo_Bar"]["Foo"] == "Bar"
def test_append_a_type_product_with_its_styles(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
history = library.createIfcOwnerHistory()
element.OwnerHistory = history
@@ -175,7 +150,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
assert self.file.by_type("IfcStyledItem")[0].Item == self.file.by_type("IfcBoundingBox")[0]
def test_append_product_with_styles_to_reuse_styleditems(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
history = library.createIfcOwnerHistory()
element_type.OwnerHistory = history
@@ -195,7 +170,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
local_context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
context = ifcopenshell.api.run("context.add_context", library, context_type="Model")
@@ -210,7 +185,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 1
def test_append_a_material(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
material = ifcopenshell.api.run("material.add_material", library, name="Material")
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=material)
assert len(self.file.by_type("IfcMaterial")) == 1
@@ -218,7 +193,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
def test_append_a_material_with_a_representation(self):
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
material = ifcopenshell.api.run("material.add_material", library, name="Material")
style = ifcopenshell.api.run("style.add_style", library)
@@ -234,7 +209,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
file_context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
material = ifcopenshell.api.run("material.add_material", library, name="Material")
style = ifcopenshell.api.run("style.add_style", library)
@@ -261,7 +236,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
target_view="MODEL_VIEW",
)
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
material = ifcopenshell.api.run("material.add_material", library, name="Material")
style = ifcopenshell.api.run("style.add_style", library)
@@ -288,7 +263,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
file_context = ifcopenshell.api.run("context.add_context", self.file, context_type="Model")
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcProject")
material = ifcopenshell.api.run("material.add_material", library, name="Material")
style = ifcopenshell.api.run("style.add_style", library)
@@ -312,48 +287,27 @@ class TestAppendAsset(test.bootstrap.IFC4):
assert subcontext.TargetView == "MODEL_VIEW"
assert subcontext.ParentContext == file_context
- def test_append_a_cost_schedule(self):
- library = ifcopenshell.api.run("project.create_file")
- schedule = ifcopenshell.api.run("cost.add_cost_schedule", library, name="Schedule")
- item = ifcopenshell.api.run("cost.add_cost_item", library, cost_schedule=schedule)
- item2 = ifcopenshell.api.run("cost.add_cost_item", library, cost_item=item)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=schedule)
- assert len(self.file.by_type("IfcCostSchedule")) == 1
- assert len(self.file.by_type("IfcCostItem")) == 2
- assert self.file.by_type("IfcCostSchedule")[0].Name == "Schedule"
- appended_item = self.file.by_type("IfcCostSchedule")[0].Controls[0].RelatedObjects[0]
- assert appended_item.is_a("IfcCostItem")
- assert appended_item.IsNestedBy[0].RelatedObjects[0].is_a("IfcCostItem")
-
def test_append_a_profile_def(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
profile = library.createIfcIShapeProfileDef()
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=profile)
assert len(self.file.by_type("IfcIShapeProfileDef")) == 1
- def test_append_a_profile_def_with_all_properties(self):
- library = ifcopenshell.api.run("project.create_file")
- profile = library.createIfcIShapeProfileDef()
- ifcopenshell.api.run("pset.add_pset", library, product=profile, name="Foo_Bar")
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=profile)
- assert len(self.file.by_type("IfcIShapeProfileDef")) == 1
- assert self.file.by_type("IfcIShapeProfileDef")[0].HasProperties[0].Name == "Foo_Bar"
-
def test_append_a_product(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
assert len(self.file.by_type("IfcWall")) == 1
def test_append_a_product_with_all_properties(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
ifcopenshell.api.run("pset.add_pset", library, product=element, name="Foo_Bar")
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
assert ifcopenshell.util.element.get_psets(self.file.by_type("IfcWall")[0])["Foo_Bar"]
def test_append_a_product_with_its_type(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
@@ -361,7 +315,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
assert ifcopenshell.util.element.get_type(self.file.by_type("IfcWall")[0]).is_a("IfcWallType")
def test_append_only_specified_occurrences_of_a_typed_product(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
element2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
element3 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
@@ -375,7 +329,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
assert len(self.file.by_type("IfcWall")) == 2
def test_append_a_product_with_materials(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
material = ifcopenshell.api.run("material.add_material", library, name="Material")
ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
@@ -383,7 +337,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
assert ifcopenshell.util.element.get_material(self.file.by_type("IfcWall")[0]).Name == "Material"
def test_append_a_product_where_its_inverse_material_relationship_refers_to_product_types_not_in_scope(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
element_type2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
@@ -396,7 +350,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
assert [e.GlobalId for e in self.file.by_type("IfcWallType")] == [element_type.GlobalId]
def test_append_a_product_with_its_styles(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
item = library.createIfcBoundingBox()
library.createIfcStyledItem(Item=item)
@@ -406,7 +360,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
assert self.file.by_type("IfcStyledItem")[0].Item == self.file.by_type("IfcBoundingBox")[0]
def test_append_a_product_with_openings(self):
- library = ifcopenshell.api.run("project.create_file")
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
opening = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcOpeningElement")
ifcopenshell.api.run("void.add_opening", library, opening=opening, element=element)
@@ -414,25 +368,50 @@ class TestAppendAsset(test.bootstrap.IFC4):
assert self.file.by_type("IfcWall")[0].HasOpenings[0].RelatedOpeningElement.is_a("IfcOpeningElement")
-class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3):
- def test_append_a_product_with_its_type(self):
- library = ifcopenshell.api.run("project.create_file", version="IFC2X3")
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
- assert ifcopenshell.util.element.get_type(self.file.by_type("IfcWall")[0]).is_a("IfcWallType")
+class TestAppendAssetIFC4(test.bootstrap.IFC4, TestAppendAssetIFC2X3):
+ # NOTE: breaks in IFC2X3 since IfcProfileDef doesn't have "HasProperties" inverse in ifc2x3
+ # and we use it in whitelisted_inverse_attributes for appending IfcProfileDef
+ def test_append_a_profile_def_with_all_properties(self):
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
+ profile = library.createIfcIShapeProfileDef()
+ ifcopenshell.api.run("pset.add_pset", library, product=profile, name="Foo_Bar")
+ ifcopenshell.api.run("project.append_asset", self.file, library=library, element=profile)
+ assert len(self.file.by_type("IfcIShapeProfileDef")) == 1
+ assert self.file.by_type("IfcIShapeProfileDef")[0].HasProperties[0].Name == "Foo_Bar"
- def test_append_only_specified_occurrences_of_a_typed_product(self):
- library = ifcopenshell.api.run("project.create_file", version="IFC2X3")
- element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- element2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- element3 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
- element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
- ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
- ifcopenshell.api.run("type.assign_type", library, related_objects=[element2], relating_type=element_type)
- ifcopenshell.api.run("type.assign_type", library, related_objects=[element3], relating_type=element_type)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
- ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element2)
- assert len(ifcopenshell.util.element.get_types(self.file.by_type("IfcWallType")[0])) == 2
- assert len(self.file.by_type("IfcWall")) == 2
+ # NOTE: breaks in IFC2X3 since IfcMaterial doesn't have "HasProperties" inverse in ifc2x3
+ # and we use it in whitelisted_inverse_attributes for appending IfcTypeProduct
+ def test_append_two_type_products_sharing_the_same_material_with_properties(self):
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
+ element1 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
+ element2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
+ material = ifcopenshell.api.run("material.add_material", library, name="Material")
+
+ pset = ifcopenshell.api.run("pset.add_pset", library, product=material, name="Foo_Bar")
+ ifcopenshell.api.run("pset.edit_pset", library, pset=pset, properties={"Foo": "Bar"})
+
+ ifcopenshell.api.run("material.assign_material", library, products=[element1], material=material)
+ ifcopenshell.api.run("material.assign_material", library, products=[element2], material=material)
+ new1 = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element1)
+ new2 = ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element2)
+
+ assert len(self.file.by_type("IfcMaterialProperties")) == 1
+ material = self.file.by_type("IfcMaterial")[0]
+ assert ifcopenshell.util.element.get_material(new1) == material
+ assert ifcopenshell.util.element.get_material(new2) == material
+ assert ifcopenshell.util.element.get_psets(material)["Foo_Bar"]["Foo"] == "Bar"
+
+ # NOTE: breaks in IFC2X3 since IfcCostItem doesn't have "IsNestedBy" inverse in ifc2x3
+ # and we use it in whitelisted_inverse_attributes for appending IfcCostSchedule
+ def test_append_a_cost_schedule(self):
+ library = ifcopenshell.api.run("project.create_file", version=self.file.schema)
+ schedule = ifcopenshell.api.run("cost.add_cost_schedule", library, name="Schedule")
+ item = ifcopenshell.api.run("cost.add_cost_item", library, cost_schedule=schedule)
+ item2 = ifcopenshell.api.run("cost.add_cost_item", library, cost_item=item)
+ ifcopenshell.api.run("project.append_asset", self.file, library=library, element=schedule)
+ assert len(self.file.by_type("IfcCostSchedule")) == 1
+ assert len(self.file.by_type("IfcCostItem")) == 2
+ assert self.file.by_type("IfcCostSchedule")[0].Name == "Schedule"
+ appended_item = self.file.by_type("IfcCostSchedule")[0].Controls[0].RelatedObjects[0]
+ assert appended_item.is_a("IfcCostItem")
+ assert appended_item.IsNestedBy[0].RelatedObjects[0].is_a("IfcCostItem")