From 17eaef778a7402f3b08754a779f4b0017c6d977d Mon Sep 17 00:00:00 2001 From: Bruno Postle Date: Mon, 30 Mar 2026 07:30:38 +0100 Subject: [PATCH] api.geometry.connect_path: add connection_geometry parameter IfcRelConnectsPathElements has an optional ConnectionGeometry attribute for recording the geometric cut-plane between adjacent elements, but there was no way to set it via the API. Generated with the assistance of an AI coding tool. --- .../ifcopenshell/api/geometry/connect_path.py | 2 ++ .../test/api/geometry/test_connect_path.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_path.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_path.py index 3135bef116..64c9fddb62 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_path.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/connect_path.py @@ -31,6 +31,7 @@ def connect_path( relating_connection: str = "NOTDEFINED", related_connection: str = "NOTDEFINED", description: Optional[str] = None, + connection_geometry: Optional[ifcopenshell.entity_instance] = None, ) -> ifcopenshell.entity_instance: incompatible_connections: list[ifcopenshell.entity_instance] = [] for rel in relating_element.ConnectedTo: @@ -73,6 +74,7 @@ def connect_path( ifcopenshell.guid.new(), OwnerHistory=ifcopenshell.api.owner.create_owner_history(file), Description=description, + ConnectionGeometry=connection_geometry, RelatingElement=relating_element, RelatedElement=related_element, RelatingConnectionType=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 bda341d2c6..0927e474ae 100644 --- a/src/ifcopenshell-python/test/api/geometry/test_connect_path.py +++ b/src/ifcopenshell-python/test/api/geometry/test_connect_path.py @@ -33,6 +33,18 @@ class TestConnectPath(test.bootstrap.IFC4): assert rel.RelatedConnectionType == "ATEND" assert rel.Description == "MITRE" + def test_storing_connection_geometry(self): + wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall") + wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall") + geometry = self.file.create_entity("IfcConnectionPointGeometry") + rel = ifcopenshell.api.geometry.connect_path( + self.file, + relating_element=wall1, + related_element=wall2, + connection_geometry=geometry, + ) + assert rel.ConnectionGeometry == geometry + def test_doing_nothing_if_the_element_is_already_connected(self): wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall") wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")