Skip to content

Commit 17eaef7

Browse files
committed
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.
1 parent f46be80 commit 17eaef7

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/ifcopenshell-python/ifcopenshell/api/geometry/connect_path.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def connect_path(
3131
relating_connection: str = "NOTDEFINED",
3232
related_connection: str = "NOTDEFINED",
3333
description: Optional[str] = None,
34+
connection_geometry: Optional[ifcopenshell.entity_instance] = None,
3435
) -> ifcopenshell.entity_instance:
3536
incompatible_connections: list[ifcopenshell.entity_instance] = []
3637
for rel in relating_element.ConnectedTo:
@@ -73,6 +74,7 @@ def connect_path(
7374
ifcopenshell.guid.new(),
7475
OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
7576
Description=description,
77+
ConnectionGeometry=connection_geometry,
7678
RelatingElement=relating_element,
7779
RelatedElement=related_element,
7880
RelatingConnectionType=relating_connection,

src/ifcopenshell-python/test/api/geometry/test_connect_path.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ def test_connecting_a_path(self):
3333
assert rel.RelatedConnectionType == "ATEND"
3434
assert rel.Description == "MITRE"
3535

36+
def test_storing_connection_geometry(self):
37+
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
38+
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
39+
geometry = self.file.create_entity("IfcConnectionPointGeometry")
40+
rel = ifcopenshell.api.geometry.connect_path(
41+
self.file,
42+
relating_element=wall1,
43+
related_element=wall2,
44+
connection_geometry=geometry,
45+
)
46+
assert rel.ConnectionGeometry == geometry
47+
3648
def test_doing_nothing_if_the_element_is_already_connected(self):
3749
wall1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
3850
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")

0 commit comments

Comments
 (0)