From 3e2ca328d2b980c03cc133eb9c0b0589602b21bd Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Thu, 9 Mar 2023 17:48:42 +1100 Subject: [PATCH] Get side area lets you choose the side axis now in util.shape. --- src/ifcopenshell-python/ifcopenshell/util/shape.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/shape.py b/src/ifcopenshell-python/ifcopenshell/util/shape.py index 6b9f642eb4..1e746098c9 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/shape.py +++ b/src/ifcopenshell-python/ifcopenshell/util/shape.py @@ -113,7 +113,7 @@ def get_area(geometry): return get_area_vf(vertices, faces) -def get_side_area(geometry): +def get_side_area(geometry, axis="Y"): verts = geometry.verts faces = geometry.faces vertices = np.array([[verts[i], verts[i + 1], verts[i + 2]] for i in range(0, len(verts), 3)]) @@ -128,7 +128,8 @@ def get_side_area(geometry): triangle_normals = triangle_normals / np.linalg.norm(triangle_normals, axis=1)[:, np.newaxis] # Find the faces with a normal vector pointing in the desired +Y normal direction - filtered_face_indices = np.where(triangle_normals[:, 1] > tol)[0] + axis = {"X": 0, "Y": 1, "Z": 2}[axis] + filtered_face_indices = np.where(triangle_normals[:, axis] > tol)[0] filtered_faces = faces[filtered_face_indices] return get_area_vf(vertices, filtered_faces)