New utility function for getting ports of an element

This commit is contained in:
Dion Moult
2022-01-24 16:16:08 +11:00
parent e38759c39d
commit 8569bcf350
2 changed files with 25 additions and 0 deletions
@@ -34,3 +34,12 @@ def get_element_systems(element):
]:
results.append(rel.RelatingGroup)
return results
def get_ports(element):
results = []
for rel in getattr(element, "IsNestedBy", []) or []:
results.extend([o for o in rel.RelatedObjects if o.is_a("IfcDistributionPort")])
for rel in element.HasPorts or []:
results.append(rel.RelatingPort)
return results