mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Update shape.py
Following the discussion in Live Chat about length of all edges in a given geometry: https://matrix.to/#/!ssOmSJysZpXBupsgjO:matrix.org/$0ZHjIFCtpwQl06xdGWlQ9ymsiKWpPuLMczVJnNYmN84?via=matrix.org&via=crossbach.de&via=infeeeee.duckdns.org
This commit is contained in:
committed by
Thomas Krijnen
parent
3f3f3b6aff
commit
e27980f746
@@ -730,3 +730,16 @@ def get_extrusions(element: ifcopenshell.entity_instance) -> list[ifcopenshell.e
|
||||
else:
|
||||
break
|
||||
return extrusions
|
||||
|
||||
|
||||
def get_total_edge_length(geometry: ShapeType) -> float:
|
||||
"""Calculates the total length of edges in a given geometry.
|
||||
|
||||
:param geometry: Geometry output calculated by IfcOpenShell
|
||||
:type geometry: geometry
|
||||
:return: The total length of all edges in the geometry.
|
||||
:rtype: float
|
||||
"""
|
||||
vertices = get_vertices(geometry)
|
||||
edges = get_edges(geometry)
|
||||
return sum([np.linalg.norm(vertices[e[0]] - vertices[e[1]]) for e in edges])
|
||||
|
||||
Reference in New Issue
Block a user