mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
material.assign_material - support batching #4474
This commit is contained in:
@@ -16,77 +16,209 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
class TestAssignMaterial(test.bootstrap.IFC4):
|
||||
class TestAssignMaterialIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_assign_element_single_material(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterial", material=material)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterial", material=material
|
||||
)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
assert element.HasAssociations[0].RelatingMaterial == material
|
||||
assert ifcopenshell.util.element.get_material(element1) == material
|
||||
assert ifcopenshell.util.element.get_material(element2) == material
|
||||
|
||||
def test_raise_exception_creating_ifc_material_without(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element], type="IfcMaterial", material=None
|
||||
)
|
||||
assert ifcopenshell.util.element.get_material(element)
|
||||
|
||||
def test_assign_type_single_material(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterial", material=material)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterial", material=material
|
||||
)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
assert element.HasAssociations[0].RelatingMaterial == material
|
||||
assert ifcopenshell.util.element.get_material(element1) == material
|
||||
assert ifcopenshell.util.element.get_material(element2) == material
|
||||
|
||||
def test_assign_type_material_layer_set(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialLayerSet")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSet"
|
||||
)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
material_set = element.HasAssociations[0].RelatingMaterial
|
||||
material_set = ifcopenshell.util.element.get_material(element1)
|
||||
assert material_set.is_a("IfcMaterialLayerSet")
|
||||
assert not material_set.MaterialLayers
|
||||
assert ifcopenshell.util.element.get_material(element2) == material_set
|
||||
|
||||
def test_assign_type_material_layer_set_and_element_layer_set_usage(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element_type, type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialLayerSetUsage")
|
||||
material_set = element_type.HasAssociations[0].RelatingMaterial
|
||||
material_usage = element.HasAssociations[0].RelatingMaterial
|
||||
assert material_usage.is_a("IfcMaterialLayerSetUsage")
|
||||
assert material_usage.ForLayerSet == material_set
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
|
||||
)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
material_set = ifcopenshell.util.element.get_material(element_type)
|
||||
material_usage1 = ifcopenshell.util.element.get_material(element1, should_inherit=False)
|
||||
assert material_usage1.is_a("IfcMaterialLayerSetUsage")
|
||||
assert material_usage1.ForLayerSet == material_set
|
||||
assert ifcopenshell.util.element.get_material(element2, should_inherit=False) == material_usage1
|
||||
|
||||
def test_assign_type_material_profile_set(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialProfileSet")
|
||||
def test_assign_type_material_layer_set_and_element_layer_set_usage_is_different_for_different_types(self):
|
||||
element_type1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type1)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element_type1], type="IfcMaterialLayerSet"
|
||||
)
|
||||
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type2)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element_type2], type="IfcMaterialLayerSet"
|
||||
)
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
material_set1 = ifcopenshell.util.element.get_material(element_type1)
|
||||
material_usage1 = ifcopenshell.util.element.get_material(element1, should_inherit=False)
|
||||
assert material_usage1.is_a("IfcMaterialLayerSetUsage")
|
||||
assert material_usage1.ForLayerSet == material_set1
|
||||
|
||||
material_set2 = ifcopenshell.util.element.get_material(element_type2)
|
||||
material_usage2 = ifcopenshell.util.element.get_material(element2, should_inherit=False)
|
||||
assert material_usage2.is_a("IfcMaterialLayerSetUsage")
|
||||
assert material_usage2.ForLayerSet == material_set2
|
||||
assert material_usage2 != material_usage1
|
||||
|
||||
def test_assign_element_layer_set_usage_is_different_for_different_layer_set_directions(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
|
||||
material_usage1 = ifcopenshell.util.element.get_material(element1, should_inherit=False)
|
||||
assert material_usage1.is_a("IfcMaterialLayerSetUsage")
|
||||
material_set1 = material_usage1.ForLayerSet
|
||||
assert material_set1.is_a("IfcMaterialLayerSet")
|
||||
assert material_usage1.LayerSetDirection == "AXIS2"
|
||||
|
||||
material_usage2 = ifcopenshell.util.element.get_material(element2, should_inherit=False)
|
||||
assert material_usage2.is_a("IfcMaterialLayerSetUsage")
|
||||
material_set2 = material_usage2.ForLayerSet
|
||||
assert material_set2.is_a("IfcMaterialLayerSet")
|
||||
assert material_usage2.LayerSetDirection == "AXIS3"
|
||||
|
||||
assert material_set1 != material_set2
|
||||
assert material_usage1 != material_usage2
|
||||
|
||||
def test_assign_element_material_list(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material",
|
||||
self.file,
|
||||
products=[element1, element2],
|
||||
type="IfcMaterialList",
|
||||
material=material,
|
||||
)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
material_set = element.HasAssociations[0].RelatingMaterial
|
||||
material_list = ifcopenshell.util.element.get_material(element1)
|
||||
assert material_list.is_a("IfcMaterialList")
|
||||
assert material_list.Materials[0] == material
|
||||
assert ifcopenshell.util.element.get_material(element2) == material_list
|
||||
|
||||
|
||||
class TestAssignMaterialIFC4(test.bootstrap.IFC4, TestAssignMaterialIFC2X3):
|
||||
def test_assign_type_material_profile_set(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialProfileSet"
|
||||
)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
material_set = ifcopenshell.util.element.get_material(element1)
|
||||
assert material_set.is_a("IfcMaterialProfileSet")
|
||||
assert not material_set.MaterialProfiles
|
||||
assert ifcopenshell.util.element.get_material(element2) == material_set
|
||||
|
||||
def test_assign_type_material_profile_set_and_element_profile_set_usage(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element_type, type="IfcMaterialProfileSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialProfileSetUsage")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
"type.assign_type", self.file, related_objects=[element1, element2], relating_type=element_type
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element_type], type="IfcMaterialProfileSet"
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialProfileSetUsage"
|
||||
)
|
||||
material_set = element_type.HasAssociations[0].RelatingMaterial
|
||||
material_usage = element.HasAssociations[0].RelatingMaterial
|
||||
assert material_usage.is_a("IfcMaterialProfileSetUsage")
|
||||
assert material_usage.ForProfileSet == material_set
|
||||
material_usage1 = element1.HasAssociations[0].RelatingMaterial
|
||||
assert material_usage1.is_a("IfcMaterialProfileSetUsage")
|
||||
assert material_usage1.ForProfileSet == material_set
|
||||
assert ifcopenshell.util.element.get_material(element2, should_inherit=False) == material_usage1
|
||||
|
||||
def test_assign_type_material_profile_set_and_element_profile_set_usage_is_different_for_different_types(self):
|
||||
element_type1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type1)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element_type1], type="IfcMaterialProfileSet"
|
||||
)
|
||||
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type2)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element_type2], type="IfcMaterialProfileSet"
|
||||
)
|
||||
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialProfileSetUsage"
|
||||
)
|
||||
material_set1 = ifcopenshell.util.element.get_material(element_type1)
|
||||
material_usage1 = ifcopenshell.util.element.get_material(element1, should_inherit=False)
|
||||
assert material_usage1.is_a("IfcMaterialProfileSetUsage")
|
||||
assert material_usage1.ForProfileSet == material_set1
|
||||
|
||||
material_set2 = ifcopenshell.util.element.get_material(element_type2)
|
||||
material_usage2 = ifcopenshell.util.element.get_material(element2, should_inherit=False)
|
||||
assert material_usage2.is_a("IfcMaterialProfileSetUsage")
|
||||
assert material_usage2.ForProfileSet == material_set2
|
||||
assert material_usage2 != material_usage1
|
||||
|
||||
def test_assign_type_material_constituent_set(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialConstituentSet")
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, products=[element1, element2], type="IfcMaterialConstituentSet"
|
||||
)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
material_set = element.HasAssociations[0].RelatingMaterial
|
||||
material_set = ifcopenshell.util.element.get_material(element1)
|
||||
assert material_set.is_a("IfcMaterialConstituentSet")
|
||||
assert not material_set.MaterialConstituents
|
||||
|
||||
def test_assign_element_material_list(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialList", material=material)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
material_list = element.HasAssociations[0].RelatingMaterial
|
||||
assert material_list.is_a("IfcMaterialList")
|
||||
assert material_list.Materials[0] == material
|
||||
assert ifcopenshell.util.element.get_material(element2) == material_set
|
||||
|
||||
@@ -31,7 +31,7 @@ class TestCopyMaterial(test.bootstrap.IFC4):
|
||||
def test_assignments_are_not_copied(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material)
|
||||
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
|
||||
|
||||
@@ -29,7 +29,7 @@ class TestRemoveMaterial(test.bootstrap.IFC4):
|
||||
def test_removing_material_with_associations(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=wall, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material)
|
||||
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")) == 0
|
||||
@@ -41,7 +41,7 @@ class TestRemoveMaterial(test.bootstrap.IFC4):
|
||||
"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, product=wall, material=material_set)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
|
||||
assert len(self.file.by_type("IfcMaterialLayerSet")[0].MaterialLayers) == 1
|
||||
ifcopenshell.api.run("material.remove_material", self.file, material=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 0
|
||||
@@ -55,7 +55,7 @@ class TestRemoveMaterial(test.bootstrap.IFC4):
|
||||
"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, product=wall, material=material_set)
|
||||
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
|
||||
@@ -69,7 +69,7 @@ class TestRemoveMaterial(test.bootstrap.IFC4):
|
||||
"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, product=wall, material=material_set)
|
||||
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
|
||||
@@ -83,7 +83,7 @@ class TestRemoveMaterial(test.bootstrap.IFC4):
|
||||
"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, product=wall, material=material_set)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material_set)
|
||||
assert len(self.file.by_type("IfcMaterialList")[0].Materials) == 1
|
||||
ifcopenshell.api.run("material.remove_material", self.file, material=material)
|
||||
assert len(self.file.by_type("IfcMaterial")) == 0
|
||||
|
||||
@@ -29,7 +29,7 @@ class TestRemoveMaterialSet(test.bootstrap.IFC4):
|
||||
def test_removing_material_set_with_associations(self):
|
||||
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material_set", self.file, set_type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=wall, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[wall], material=material)
|
||||
ifcopenshell.api.run("material.remove_material_set", self.file, material=material)
|
||||
assert len(self.file.by_type("IfcMaterialLayerSet")) == 0
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
|
||||
|
||||
@@ -26,7 +26,7 @@ class TestUnassignMaterial(test.bootstrap.IFC4):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, product=element, type="IfcMaterial", material=material
|
||||
"material.assign_material", self.file, products=[element], type="IfcMaterial", material=material
|
||||
)
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, product=element)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
|
||||
@@ -38,10 +38,10 @@ class TestUnassignMaterial(test.bootstrap.IFC4):
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, product=element1, type="IfcMaterial", material=material
|
||||
"material.assign_material", self.file, products=[element1], type="IfcMaterial", material=material
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, product=element2, type="IfcMaterial", material=material
|
||||
"material.assign_material", self.file, products=[element2], type="IfcMaterial", material=material
|
||||
)
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, product=element2)
|
||||
assert element1.HasAssociations
|
||||
@@ -53,7 +53,7 @@ class TestUnassignMaterial(test.bootstrap.IFC4):
|
||||
def test_unassign_material_layer_set_from_type(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, product=element)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
|
||||
assert len(self.file.by_type("IfcWallType")) == 1
|
||||
@@ -64,8 +64,8 @@ class TestUnassignMaterial(test.bootstrap.IFC4):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element_type, type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialLayerSetUsage")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialLayerSetUsage")
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, product=element)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
assert element_type.HasAssociations
|
||||
@@ -81,9 +81,9 @@ class TestUnassignMaterial(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element2], relating_type=element_type)
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element_type, type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
|
||||
rel = ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, product=element, type="IfcMaterialLayerSetUsage"
|
||||
"material.assign_material", self.file, products=[element], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
|
||||
# In some invalid IFCs from Revit, they reuse usages. Let's recreate this invalid scenario
|
||||
@@ -105,7 +105,7 @@ class TestUnassignMaterial(test.bootstrap.IFC4):
|
||||
def test_unassign_material_profile_set_from_type(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialProfileSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialProfileSet")
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, product=element)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
|
||||
assert len(self.file.by_type("IfcWallType")) == 1
|
||||
@@ -116,8 +116,8 @@ class TestUnassignMaterial(test.bootstrap.IFC4):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element_type, type="IfcMaterialProfileSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialProfileSetUsage")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialProfileSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialProfileSetUsage")
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, product=element)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
assert element_type.HasAssociations
|
||||
@@ -129,7 +129,7 @@ class TestUnassignMaterial(test.bootstrap.IFC4):
|
||||
def test_unassign_material_constituent_set_from_type(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialConstituentSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialConstituentSet")
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, product=element)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
|
||||
assert len(self.file.by_type("IfcWallType")) == 1
|
||||
@@ -139,7 +139,7 @@ class TestUnassignMaterial(test.bootstrap.IFC4):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, product=element, type="IfcMaterialList", material=material
|
||||
"material.assign_material", self.file, products=[element], type="IfcMaterialList", material=material
|
||||
)
|
||||
ifcopenshell.api.run("material.unassign_material", self.file, product=element)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 0
|
||||
|
||||
@@ -70,8 +70,8 @@ class TestAppendAsset(test.bootstrap.IFC4):
|
||||
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")
|
||||
ifcopenshell.api.run("material.assign_material", library, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, product=element2, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element2], material=material)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
assert len(self.file.by_type("IfcWallType")) == 1
|
||||
|
||||
@@ -79,7 +79,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
|
||||
library = ifcopenshell.api.run("project.create_file")
|
||||
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, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
assert self.file.by_type("IfcWallType")[0].HasAssociations[0].RelatingMaterial.Name == "Material"
|
||||
|
||||
@@ -90,9 +90,9 @@ class TestAppendAsset(test.bootstrap.IFC4):
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
ifcopenshell.api.run("material.assign_material", library, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, product=element_type, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, product=element_type2, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element_type], material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element_type2], material=material)
|
||||
|
||||
# appending another type not connected to IfcWall directly
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element_type2)
|
||||
@@ -111,8 +111,8 @@ class TestAppendAsset(test.bootstrap.IFC4):
|
||||
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, product=element1, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, product=element2, material=material)
|
||||
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)
|
||||
|
||||
@@ -139,8 +139,8 @@ class TestAppendAsset(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.run("material.add_layer", library, layer_set=layer_set2, material=material)
|
||||
ifcopenshell.api.run("material.add_layer", library, layer_set=layer_set2, material=material)
|
||||
|
||||
ifcopenshell.api.run("material.assign_material", library, product=element1, material=layer_set1)
|
||||
ifcopenshell.api.run("material.assign_material", library, product=element2, material=layer_set2)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element1], material=layer_set1)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element2], material=layer_set2)
|
||||
|
||||
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)
|
||||
@@ -160,7 +160,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
|
||||
element.OwnerHistory = history
|
||||
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
rel = ifcopenshell.api.run("material.assign_material", library, product=element, material=material)
|
||||
rel = ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
|
||||
# We share a history. This ensures that we continue to check all
|
||||
# whitelisted inverses even though one of the subelements (i.e. this
|
||||
# shared history) is already processed. See bug #2837.
|
||||
@@ -201,7 +201,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
|
||||
|
||||
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, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
|
||||
style = ifcopenshell.api.run("style.add_style", library)
|
||||
ifcopenshell.api.run("style.assign_material_style", library, material=material, style=style, context=context)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
@@ -378,7 +378,7 @@ class TestAppendAsset(test.bootstrap.IFC4):
|
||||
library = ifcopenshell.api.run("project.create_file")
|
||||
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, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
assert ifcopenshell.util.element.get_material(self.file.by_type("IfcWall")[0]).Name == "Material"
|
||||
|
||||
@@ -389,9 +389,9 @@ class TestAppendAsset(test.bootstrap.IFC4):
|
||||
element_type2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", library, related_objects=[element], relating_type=element_type)
|
||||
material = ifcopenshell.api.run("material.add_material", library, name="Material")
|
||||
ifcopenshell.api.run("material.assign_material", library, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, product=element_type, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, product=element_type2, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element], material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element_type], material=material)
|
||||
ifcopenshell.api.run("material.assign_material", library, products=[element_type2], material=material)
|
||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
||||
assert [e.GlobalId for e in self.file.by_type("IfcWallType")] == [element_type.GlobalId]
|
||||
|
||||
|
||||
@@ -369,7 +369,7 @@ class TestRemoveProduct(test.bootstrap.IFC4):
|
||||
def test_removing_all_material_relationships_of_an_element(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="Foo")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
|
||||
ifcopenshell.api.run("root.remove_product", self.file, product=element)
|
||||
assert not self.file.by_type("IfcRelAssociatesMaterial")
|
||||
assert self.file.by_type("IfcMaterial")
|
||||
|
||||
@@ -75,7 +75,7 @@ class TestAssignMaterialStyle(test.bootstrap.IFC4):
|
||||
"material.add_constituent", self.file, constituent_set=material_set, material=material
|
||||
)
|
||||
constituent.Name = name
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material_set)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
|
||||
|
||||
ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style, context=context)
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class TestAssignMaterialStyle(test.bootstrap.IFC4):
|
||||
"material.add_constituent", self.file, constituent_set=material_set, material=material
|
||||
)
|
||||
constituent.Name = name
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material_set)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
|
||||
|
||||
ifcopenshell.api.run("style.assign_material_style", self.file, material=material, style=style, context=context)
|
||||
ifcopenshell.api.run(
|
||||
|
||||
@@ -164,3 +164,13 @@ class TestTemporarySupportForDeprecatedAPIArguments(test.bootstrap.IFC4):
|
||||
|
||||
ifcopenshell.api.run("system.unassign_system", self.file, product=element2, system=system)
|
||||
assert ifcopenshell.util.system.get_system_elements(system) == []
|
||||
|
||||
@deprecation_check
|
||||
def test_assign_element_single_material(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, product=element, type="IfcMaterial", material=material
|
||||
)
|
||||
assert len(self.file.by_type("IfcRelAssociatesMaterial")) == 1
|
||||
assert element.HasAssociations[0].RelatingMaterial == material
|
||||
|
||||
@@ -71,7 +71,7 @@ class TestAssignType(test.bootstrap.IFC4):
|
||||
context = self.file.createIfcGeometricRepresentationContext()
|
||||
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
|
||||
ifcopenshell.api.run("geometry.assign_representation", self.file, product=element_type, representation=rep)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element_type, type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
|
||||
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run(
|
||||
@@ -120,7 +120,7 @@ class TestAssignType(test.bootstrap.IFC4):
|
||||
material_types += ("IfcMaterialProfileSet",)
|
||||
for material_type in material_types:
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element_type, type=material_type)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type=material_type)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
|
||||
material = ifcopenshell.util.element.get_material(element)
|
||||
@@ -130,7 +130,7 @@ class TestAssignType(test.bootstrap.IFC4):
|
||||
def test_do_not_reassign_material_if_it_was_assigned_previously(self):
|
||||
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element_type, type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element1], relating_type=element_type)
|
||||
assert (material := ifcopenshell.util.element.get_material(element1))
|
||||
material_id = material.id()
|
||||
|
||||
@@ -48,7 +48,7 @@ class TestUnassignType(test.bootstrap.IFC4):
|
||||
context = self.file.createIfcGeometricRepresentationContext()
|
||||
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
|
||||
ifcopenshell.api.run("geometry.assign_representation", self.file, product=element_type, representation=rep)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element_type, type="IfcMaterialLayerSet")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], type="IfcMaterialLayerSet")
|
||||
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
|
||||
|
||||
@@ -339,52 +339,52 @@ class TestGetMaterial(test.bootstrap.IFC4):
|
||||
def test_getting_the_material_of_a_product(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
|
||||
assert subject.get_material(element) == material
|
||||
|
||||
def test_getting_a_material_list_of_a_product(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
rel = ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, product=element, type="IfcMaterialList", material=material
|
||||
"material.assign_material", self.file, products=[element], type="IfcMaterialList", material=material
|
||||
)
|
||||
assert subject.get_material(element) == rel.RelatingMaterial
|
||||
|
||||
def test_getting_a_material_layer_set_of_a_product(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialLayerSet")
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialLayerSet")
|
||||
assert subject.get_material(element) == rel.RelatingMaterial
|
||||
|
||||
def test_getting_a_material_profile_set_of_a_product(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialProfileSet")
|
||||
rel = ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialProfileSet")
|
||||
assert subject.get_material(element) == rel.RelatingMaterial
|
||||
|
||||
def test_getting_a_material_layer_set_usage_of_a_product(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, product=element, type="IfcMaterialLayerSetUsage"
|
||||
"material.assign_material", self.file, products=[element], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
assert subject.get_material(element) == rel.RelatingMaterial
|
||||
|
||||
def test_getting_a_material_profile_set_usage_of_a_product(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, product=element, type="IfcMaterialProfileSetUsage"
|
||||
"material.assign_material", self.file, products=[element], type="IfcMaterialProfileSetUsage"
|
||||
)
|
||||
assert subject.get_material(element) == rel.RelatingMaterial
|
||||
|
||||
def test_getting_a_material_layer_set_indirectly_from_an_assigned_usage(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, product=element, type="IfcMaterialLayerSetUsage"
|
||||
"material.assign_material", self.file, products=[element], type="IfcMaterialLayerSetUsage"
|
||||
)
|
||||
assert subject.get_material(element, should_skip_usage=True) == rel.RelatingMaterial.ForLayerSet
|
||||
|
||||
def test_getting_a_material_profile_set_indirectly_from_an_assigned_usage(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
rel = ifcopenshell.api.run(
|
||||
"material.assign_material", self.file, product=element, type="IfcMaterialProfileSetUsage"
|
||||
"material.assign_material", self.file, products=[element], type="IfcMaterialProfileSetUsage"
|
||||
)
|
||||
assert subject.get_material(element, should_skip_usage=True) == rel.RelatingMaterial.ForProfileSet
|
||||
|
||||
@@ -393,7 +393,7 @@ class TestGetMaterial(test.bootstrap.IFC4):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element_type, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], material=material)
|
||||
assert subject.get_material(element) == material
|
||||
|
||||
def test_getting_an_overridden_material_from_the_elements_occurrence(self):
|
||||
@@ -401,9 +401,9 @@ class TestGetMaterial(test.bootstrap.IFC4):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element_type, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], material=material)
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
|
||||
assert subject.get_material(element) == material
|
||||
|
||||
def test_getting_direct_materials_without_checking_inheritance(self):
|
||||
@@ -411,7 +411,7 @@ class TestGetMaterial(test.bootstrap.IFC4):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[element], relating_type=element_type)
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element_type, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], material=material)
|
||||
assert subject.get_material(element, should_inherit=False) is None
|
||||
|
||||
|
||||
@@ -419,7 +419,7 @@ class TestGetMaterials(test.bootstrap.IFC4):
|
||||
def test_getting_the_materials_of_a_product(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
|
||||
assert subject.get_materials(element) == [material]
|
||||
|
||||
|
||||
@@ -440,7 +440,7 @@ class TestGetStyles(test.bootstrap.IFC4):
|
||||
)
|
||||
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
|
||||
|
||||
style = ifcopenshell.api.run("style.add_style", self.file)
|
||||
ifcopenshell.api.run(
|
||||
@@ -487,7 +487,7 @@ class TestGetElementsByMaterial(test.bootstrap.IFC4):
|
||||
def test_getting_elements_of_a_material(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
|
||||
assert subject.get_elements_by_material(self.file, material) == {element}
|
||||
|
||||
def test_getting_elements_of_a_material_layer_set(self):
|
||||
@@ -497,8 +497,8 @@ class TestGetElementsByMaterial(test.bootstrap.IFC4):
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
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, product=element_type, material=material_set)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialLayerSetUsage")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], material=material_set)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialLayerSetUsage")
|
||||
usage = self.file.by_type("IfcMaterialLayerSetUsage")[0]
|
||||
assert subject.get_elements_by_material(self.file, material) == {element, element_type}
|
||||
assert subject.get_elements_by_material(self.file, material_set) == {element, element_type}
|
||||
@@ -511,8 +511,8 @@ class TestGetElementsByMaterial(test.bootstrap.IFC4):
|
||||
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, product=element_type, material=material_set)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialProfileSetUsage")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element_type], material=material_set)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], type="IfcMaterialProfileSetUsage")
|
||||
usage = self.file.by_type("IfcMaterialProfileSetUsage")[0]
|
||||
assert subject.get_elements_by_material(self.file, material) == {element, element_type}
|
||||
assert subject.get_elements_by_material(self.file, material_set) == {element, element_type}
|
||||
@@ -525,7 +525,7 @@ class TestGetElementsByMaterial(test.bootstrap.IFC4):
|
||||
"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, product=element, material=material_set)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
|
||||
assert subject.get_elements_by_material(self.file, material) == {element}
|
||||
assert subject.get_elements_by_material(self.file, material_set) == {element}
|
||||
|
||||
@@ -534,7 +534,7 @@ class TestGetElementsByMaterial(test.bootstrap.IFC4):
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
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, product=element, material=material_set)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
|
||||
assert subject.get_elements_by_material(self.file, material) == {element}
|
||||
assert subject.get_elements_by_material(self.file, material_set) == {element}
|
||||
|
||||
@@ -585,7 +585,7 @@ class TestGetElementsByStyle(test.bootstrap.IFC4):
|
||||
def test_getting_elements_of_a_styled_material(self):
|
||||
element = self.file.createIfcWall()
|
||||
material = ifcopenshell.api.run("material.add_material", self.file)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
|
||||
style = self.file.createIfcSurfaceStyle()
|
||||
self.file.createIfcMaterialDefinitionRepresentation(
|
||||
RepresentedMaterial=material,
|
||||
|
||||
@@ -85,7 +85,7 @@ class TestGetElementValue(test.bootstrap.IFC4):
|
||||
layer = ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
|
||||
layer.Name = "L2"
|
||||
ifcopenshell.api.run("material.edit_layer", self.file, layer=layer, attributes={"LayerThickness": 13})
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material_set)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
|
||||
assert subject.get_element_value(element, "material.MaterialLayers.Name") == ["L1", "L2"]
|
||||
# Allow to use "item" to generically select an item in a material set
|
||||
assert subject.get_element_value(element, "material.item.Name") == ["L1", "L2"]
|
||||
@@ -109,7 +109,7 @@ class TestGetElementValue(test.bootstrap.IFC4):
|
||||
)
|
||||
layer = ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
|
||||
layer.Name = "L1"
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material_set)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
|
||||
assert subject.get_element_value(element, "material.item.Name.0") == "L1"
|
||||
assert subject.get_element_value(element, "material.item.Name.1") is None
|
||||
|
||||
@@ -180,7 +180,7 @@ class TestFilterElements(test.bootstrap.IFC4):
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
assert subject.filter_elements(self.file, "IfcWall, material=NULL") == {element, element2}
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
|
||||
assert subject.filter_elements(self.file, "IfcWall, material=CON01") == {element}
|
||||
assert subject.filter_elements(self.file, "IfcWall, material!=CON01") == {element2}
|
||||
|
||||
@@ -511,7 +511,7 @@ class TestSelector(test.bootstrap.IFC4):
|
||||
def test_selecting_via_a_material(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material)
|
||||
assert set(subject.Selector.parse(self.file, '.IfcWall[material.Name="CON01"]')) == {element}
|
||||
|
||||
def test_selecting_via_a_material_set(self):
|
||||
@@ -522,7 +522,7 @@ class TestSelector(test.bootstrap.IFC4):
|
||||
)
|
||||
layer = ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
|
||||
ifcopenshell.api.run("material.edit_layer", self.file, layer=layer, attributes={"LayerThickness": 13})
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material_set)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
|
||||
assert set(subject.Selector.parse(self.file, '.IfcWall[material.LayerSetName="FOO"]')) == {element}
|
||||
|
||||
def test_selecting_via_a_material_set_item(self):
|
||||
@@ -534,7 +534,7 @@ class TestSelector(test.bootstrap.IFC4):
|
||||
)
|
||||
layer = ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material)
|
||||
layer = ifcopenshell.api.run("material.add_layer", self.file, layer_set=material_set, material=material2)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, product=element, material=material_set)
|
||||
ifcopenshell.api.run("material.assign_material", self.file, products=[element], material=material_set)
|
||||
assert set(subject.Selector.parse(self.file, '.IfcWall[material.item.Material.Name="CON01"]')) == {element}
|
||||
assert set(subject.Selector.parse(self.file, '.IfcWall[material.item.Material.Name="CON02"]')) == {element}
|
||||
assert set(subject.Selector.parse(self.file, '.IfcWall[material.item.Material.Name="CON03"]')) == set()
|
||||
|
||||
Reference in New Issue
Block a user