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
@@ -17,17 +17,18 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.root
import ifcopenshell.api.group
class TestAssignGroup(test.bootstrap.IFC4):
def test_group_unassignment(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
element3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
group = ifcopenshell.api.run("group.add_group", self.file)
ifcopenshell.api.run("group.assign_group", self.file, products=[element, element2, element3], group=group)
ifcopenshell.api.run("group.unassign_group", self.file, products=[element2, element3], group=group)
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
element3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
group = ifcopenshell.api.group.add_group(self.file)
ifcopenshell.api.group.assign_group(self.file, products=[element, element2, element3], group=group)
ifcopenshell.api.group.unassign_group(self.file, products=[element2, element3], group=group)
assert len(rels := self.file.by_type("IfcRelAssignsToGroup")) == 1
rel = rels[0]
@@ -35,11 +36,11 @@ class TestAssignGroup(test.bootstrap.IFC4):
assert rel.RelatedObjects == (element,)
def test_remove_relationship_unassigning_last_element(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
group = ifcopenshell.api.run("group.add_group", self.file)
ifcopenshell.api.run("group.assign_group", self.file, products=[element, element2], group=group)
ifcopenshell.api.run("group.unassign_group", self.file, products=[element, element2], group=group)
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
group = ifcopenshell.api.group.add_group(self.file)
ifcopenshell.api.group.assign_group(self.file, products=[element, element2], group=group)
ifcopenshell.api.group.unassign_group(self.file, products=[element, element2], group=group)
assert len(self.file.by_type("IfcRelAssignsToGroup")) == 0