mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 18:12:28 +00:00
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.
This commit is contained in:
@@ -31,6 +31,7 @@ def connect_path(
|
|||||||
relating_connection: str = "NOTDEFINED",
|
relating_connection: str = "NOTDEFINED",
|
||||||
related_connection: str = "NOTDEFINED",
|
related_connection: str = "NOTDEFINED",
|
||||||
description: Optional[str] = None,
|
description: Optional[str] = None,
|
||||||
|
connection_geometry: Optional[ifcopenshell.entity_instance] = None,
|
||||||
) -> ifcopenshell.entity_instance:
|
) -> ifcopenshell.entity_instance:
|
||||||
incompatible_connections: list[ifcopenshell.entity_instance] = []
|
incompatible_connections: list[ifcopenshell.entity_instance] = []
|
||||||
for rel in relating_element.ConnectedTo:
|
for rel in relating_element.ConnectedTo:
|
||||||
@@ -73,6 +74,7 @@ def connect_path(
|
|||||||
ifcopenshell.guid.new(),
|
ifcopenshell.guid.new(),
|
||||||
OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
|
OwnerHistory=ifcopenshell.api.owner.create_owner_history(file),
|
||||||
Description=description,
|
Description=description,
|
||||||
|
ConnectionGeometry=connection_geometry,
|
||||||
RelatingElement=relating_element,
|
RelatingElement=relating_element,
|
||||||
RelatedElement=related_element,
|
RelatedElement=related_element,
|
||||||
RelatingConnectionType=relating_connection,
|
RelatingConnectionType=relating_connection,
|
||||||
|
|||||||
@@ -33,6 +33,18 @@ class TestConnectPath(test.bootstrap.IFC4):
|
|||||||
assert rel.RelatedConnectionType == "ATEND"
|
assert rel.RelatedConnectionType == "ATEND"
|
||||||
assert rel.Description == "MITRE"
|
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):
|
def test_doing_nothing_if_the_element_is_already_connected(self):
|
||||||
wall1 = ifcopenshell.api.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")
|
wall2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||||
|
|||||||
Reference in New Issue
Block a user