From 13a387cc73ab4998894dd523afcd9b54e1208b55 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 23 Sep 2022 23:00:27 +1000 Subject: [PATCH] Add support for descriptions in path connection relationships --- .../ifcopenshell/api/geometry/connect_path.py | 2 ++ .../test/api/geometry/test_connect_path.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_path.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_path.py index 8450ab8e96..5d79961f82 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_path.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_path.py @@ -28,6 +28,7 @@ class Usecase: "related_element": None, "relating_connection": "NOTDEFINED", "related_connection": "NOTDEFINED", + "description": None, } for key, value in settings.items(): self.settings[key] = value @@ -73,6 +74,7 @@ class Usecase: return self.file.createIfcRelConnectsPathElements( ifcopenshell.guid.new(), OwnerHistory=ifcopenshell.api.run("owner.create_owner_history", self.file), + Description=self.settings["description"], RelatingElement=self.settings["relating_element"], RelatedElement=self.settings["related_element"], RelatingConnectionType=self.settings["relating_connection"], diff --git a/src/ifcopenshell-python/test/api/geometry/test_connect_path.py b/src/ifcopenshell-python/test/api/geometry/test_connect_path.py index 440c407e89..d5b38b8d30 100644 --- a/src/ifcopenshell-python/test/api/geometry/test_connect_path.py +++ b/src/ifcopenshell-python/test/api/geometry/test_connect_path.py @@ -24,12 +24,13 @@ 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") - rel = self.connect_path(wall1, wall2, "ATSTART", "ATEND") + rel = self.connect_path(wall1, wall2, "ATSTART", "ATEND", description="MITRE") assert rel.is_a("IfcRelConnectsPathElements") assert rel.RelatingElement == wall1 assert rel.RelatedElement == wall2 assert rel.RelatingConnectionType == "ATSTART" assert rel.RelatedConnectionType == "ATEND" + 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") @@ -129,7 +130,12 @@ class TestConnectPath(test.bootstrap.IFC4): assert len(self.file.by_type("IfcRelConnectsPathElements")) == 1 def connect_path( - self, relating_element, related_element, relating_connection="NOTDEFINED", related_connection="NOTDEFINED" + self, + relating_element, + related_element, + relating_connection="NOTDEFINED", + related_connection="NOTDEFINED", + description=None, ): return ifcopenshell.api.run( "geometry.connect_path", @@ -138,4 +144,5 @@ class TestConnectPath(test.bootstrap.IFC4): related_element=related_element, relating_connection=relating_connection, related_connection=related_connection, + description=description, )