Skip to content

Commit

Permalink
FIX: add axis compatibility for elements with no joints
Browse files Browse the repository at this point in the history
  • Loading branch information
9and3 committed Nov 28, 2024
1 parent 5aa776c commit 53a04a1
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/gh/diffCheck/diffCheck/df_geometries.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,12 @@ def compute_axis(self, is_unitized: bool = True) -> rg.Line:
:return axis: The axis of the beam as a line
"""
joints = self.joints
joint1 = joints[0]
joint2 = joints[1]
max_distance = 0
joint1 = None
joint2 = None
if len(joints) > 2:
joint1 = joints[0]
joint2 = joints[1]
max_distance = 0
for j1 in joints:
for j2 in joints:
distance = rg.Point3d.DistanceTo(
Expand All @@ -480,6 +482,22 @@ def compute_axis(self, is_unitized: bool = True) -> rg.Line:
max_distance = distance
joint1 = j1
joint2 = j2
else:
#get the two farthest dffaces for simplicity
df_faces = [face for face in self.faces]
max_distance = 0
for i in range(len(df_faces)):
for j in range(i+1, len(df_faces)):
distance = rg.Point3d.DistanceTo(
df_faces[i].center.to_rg_point3d(),
df_faces[j].center.to_rg_point3d())
if distance > max_distance:
max_distance = distance
joint1 = df_faces[i]
joint2 = df_faces[j]

if joint1 is None or joint2 is None:
raise ValueError("The beam axis cannot be calculated")

axis_ln = rg.Line(
joint1.center.to_rg_point3d(),
Expand Down

0 comments on commit 53a04a1

Please sign in to comment.