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:
@@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user