Replace all ifcopenshell.api.run with ifcopenshell.api static functions.

This commit is contained in:
Dion Moult
2024-06-28 12:36:31 +10:00
parent b5d613989e
commit 07060fc769
432 changed files with 4633 additions and 4856 deletions
@@ -18,41 +18,44 @@
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.type
import ifcopenshell.api.root
import ifcopenshell.api.geometry
class TestAssignRepresentation(test.bootstrap.IFC4):
def test_assigning_to_a_product(self):
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
rep = self.file.createIfcShapeRepresentation()
ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep)
ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep)
assert wall.Representation.Representations == (rep,)
def test_assigning_to_a_product_with_existing_representations(self):
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
rep = self.file.createIfcShapeRepresentation()
rep2 = self.file.createIfcShapeRepresentation()
ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep)
ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep2)
ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep)
ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep2)
assert wall.Representation.Representations == (rep, rep2)
def test_assigning_to_a_type_product(self):
walltype = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
walltype = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
rep = self.file.createIfcShapeRepresentation()
rep2 = self.file.createIfcShapeRepresentation()
ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep)
ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep2)
ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep)
ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep2)
assert walltype.RepresentationMaps[0].MappedRepresentation == rep
assert walltype.RepresentationMaps[1].MappedRepresentation == rep2
def test_assigning_to_a_type_will_map_representations_to_instances(self):
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
walltype = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[wall], relating_type=walltype)
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
walltype = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
ifcopenshell.api.type.assign_type(self.file, related_objects=[wall], relating_type=walltype)
context = self.file.createIfcGeometricRepresentationContext()
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
rep2 = self.file.createIfcShapeRepresentation(ContextOfItems=context)
ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep)
ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep2)
ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep)
ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep2)
assert wall.Representation.Representations[0].RepresentationType == "MappedRepresentation"
assert wall.Representation.Representations[0].Items[0].MappingSource.MappedRepresentation == rep
assert wall.Representation.Representations[0].Items[0].MappingSource == walltype.RepresentationMaps[0]
@@ -65,13 +68,13 @@ class TestAssignRepresentation(test.bootstrap.IFC4):
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
rep2 = self.file.createIfcShapeRepresentation(ContextOfItems=context)
walltype = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
ifcopenshell.api.run("geometry.assign_representation", self.file, product=walltype, representation=rep)
walltype = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
ifcopenshell.api.geometry.assign_representation(self.file, product=walltype, representation=rep)
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[wall], relating_type=walltype)
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
ifcopenshell.api.type.assign_type(self.file, related_objects=[wall], relating_type=walltype)
ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep2)
ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep2)
assert wall.Representation.Representations[0].RepresentationType == "MappedRepresentation"
assert wall.Representation.Representations[0].Items[0].MappingSource.MappedRepresentation == rep
assert walltype.RepresentationMaps[0].MappedRepresentation == rep
@@ -82,10 +85,10 @@ class TestAssignRepresentation(test.bootstrap.IFC4):
def test_assigning_to_an_instance_with_a_nongeometric_type_only_adds_it_to_the_instance(self):
context = self.file.createIfcGeometricRepresentationContext()
rep = self.file.createIfcShapeRepresentation(ContextOfItems=context)
walltype = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
wall = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
ifcopenshell.api.run("type.assign_type", self.file, related_objects=[wall], relating_type=walltype)
ifcopenshell.api.run("geometry.assign_representation", self.file, product=wall, representation=rep)
walltype = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
ifcopenshell.api.type.assign_type(self.file, related_objects=[wall], relating_type=walltype)
ifcopenshell.api.geometry.assign_representation(self.file, product=wall, representation=rep)
assert wall.Representation.Representations[0].RepresentationType != "MappedRepresentation"
assert wall.Representation.Representations[0] == rep
assert not walltype.RepresentationMaps