File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
src/gh/diffCheck/diffCheck Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -467,10 +467,12 @@ def compute_axis(self, is_unitized: bool = True) -> rg.Line:
467467 :return axis: The axis of the beam as a line
468468 """
469469 joints = self .joints
470- joint1 = joints [0 ]
471- joint2 = joints [1 ]
472- max_distance = 0
470+ joint1 = None
471+ joint2 = None
473472 if len (joints ) > 2 :
473+ joint1 = joints [0 ]
474+ joint2 = joints [1 ]
475+ max_distance = 0
474476 for j1 in joints :
475477 for j2 in joints :
476478 distance = rg .Point3d .DistanceTo (
@@ -480,6 +482,22 @@ def compute_axis(self, is_unitized: bool = True) -> rg.Line:
480482 max_distance = distance
481483 joint1 = j1
482484 joint2 = j2
485+ else :
486+ #get the two farthest dffaces for simplicity
487+ df_faces = [face for face in self .faces ]
488+ max_distance = 0
489+ for i in range (len (df_faces )):
490+ for j in range (i + 1 , len (df_faces )):
491+ distance = rg .Point3d .DistanceTo (
492+ df_faces [i ].center .to_rg_point3d (),
493+ df_faces [j ].center .to_rg_point3d ())
494+ if distance > max_distance :
495+ max_distance = distance
496+ joint1 = df_faces [i ]
497+ joint2 = df_faces [j ]
498+
499+ if joint1 is None or joint2 is None :
500+ raise ValueError ("The beam axis cannot be calculated" )
483501
484502 axis_ln = rg .Line (
485503 joint1 .center .to_rg_point3d (),
You can’t perform that action at this time.
0 commit comments