mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 10:06:47 +00:00
Replace all ifcopenshell.api.run with ifcopenshell.api static functions.
This commit is contained in:
@@ -17,13 +17,14 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.geometry
|
||||
|
||||
|
||||
class TestConnectPath(test.bootstrap.IFC4):
|
||||
def test_connecting_a_path(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel = self.connect_path(wall1, wall2, "ATSTART", "ATEND", description="MITRE")
|
||||
assert rel.is_a("IfcRelConnectsPathElements")
|
||||
assert rel.RelatingElement == wall1
|
||||
@@ -33,34 +34,34 @@ class TestConnectPath(test.bootstrap.IFC4):
|
||||
assert rel.Description == "MITRE"
|
||||
|
||||
def test_doing_nothing_if_the_element_is_already_connected(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
self.connect_path(wall1, wall2)
|
||||
total_elements = len([e for e in self.file])
|
||||
self.connect_path(wall1, wall2)
|
||||
assert len([e for e in self.file]) == total_elements
|
||||
|
||||
def test_updating_the_connection_type_if_already_connected(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=wall1, related_element=wall2)
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.geometry.connect_path(self.file, relating_element=wall1, related_element=wall2)
|
||||
total_elements = len([e for e in self.file])
|
||||
rel = self.connect_path(wall1, wall2, "ATSTART")
|
||||
assert rel.RelatingConnectionType == "ATSTART"
|
||||
assert rel.RelatedConnectionType == "NOTDEFINED"
|
||||
|
||||
def test_preventing_cyclical_connections(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=wall1, related_element=wall2)
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
ifcopenshell.api.geometry.connect_path(self.file, relating_element=wall1, related_element=wall2)
|
||||
total_elements = len([e for e in self.file])
|
||||
ifcopenshell.api.run("geometry.connect_path", self.file, relating_element=wall2, related_element=wall1)
|
||||
ifcopenshell.api.geometry.connect_path(self.file, relating_element=wall2, related_element=wall1)
|
||||
assert len([e for e in self.file]) == total_elements
|
||||
|
||||
def test_a_relating_element_can_have_multiple_path_connections(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall1, wall2, "ATPATH", "ATEND")
|
||||
rel2 = self.connect_path(wall1, wall3, "ATPATH", "ATSTART")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 2
|
||||
@@ -74,57 +75,57 @@ class TestConnectPath(test.bootstrap.IFC4):
|
||||
assert rel2.RelatedConnectionType == "ATSTART"
|
||||
|
||||
def test_a_element_can_only_have_up_to_one_start_or_end_connections(self):
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall1, wall2, "ATSTART", "ATEND")
|
||||
rel2 = self.connect_path(wall1, wall3, "ATEND", "ATSTART")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 2
|
||||
|
||||
self.file = ifcopenshell.file()
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall1, wall2, "ATSTART", "ATEND")
|
||||
rel2 = self.connect_path(wall1, wall3, "ATSTART", "ATSTART")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1
|
||||
|
||||
self.file = ifcopenshell.file()
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall1, wall2, "ATEND", "ATEND")
|
||||
rel2 = self.connect_path(wall1, wall3, "ATEND", "ATSTART")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1
|
||||
|
||||
self.file = ifcopenshell.file()
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall1, wall2, "ATPATH", "ATEND")
|
||||
rel2 = self.connect_path(wall1, wall3, "ATPATH", "ATSTART")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 2
|
||||
|
||||
self.file = ifcopenshell.file()
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall2, wall1, "ATPATH", "ATEND")
|
||||
rel2 = self.connect_path(wall3, wall1, "ATPATH", "ATSTART")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 2
|
||||
|
||||
self.file = ifcopenshell.file()
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall2, wall1, "ATPATH", "ATSTART")
|
||||
rel2 = self.connect_path(wall3, wall1, "ATPATH", "ATSTART")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1
|
||||
|
||||
self.file = ifcopenshell.file()
|
||||
wall1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
wall3 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
rel1 = self.connect_path(wall2, wall1, "ATPATH", "ATEND")
|
||||
rel2 = self.connect_path(wall3, wall1, "ATPATH", "ATEND")
|
||||
assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1
|
||||
@@ -137,8 +138,7 @@ class TestConnectPath(test.bootstrap.IFC4):
|
||||
related_connection="NOTDEFINED",
|
||||
description=None,
|
||||
):
|
||||
return ifcopenshell.api.run(
|
||||
"geometry.connect_path",
|
||||
return ifcopenshell.api.geometry.connect_path(
|
||||
self.file,
|
||||
relating_element=relating_element,
|
||||
related_element=related_element,
|
||||
|
||||
Reference in New Issue
Block a user