11#! python3
22
3- from diffCheck import diffcheck_bindings
43from diffCheck import df_cvt_bindings
54from diffCheck import df_poses
65
1413class DFMainPCAxes (component ):
1514 def RunScript (self ,
1615 i_clouds : System .Collections .Generic .List [Rhino .Geometry .PointCloud ],
16+ i_assembly ,
17+ i_save : bool ,
1718 i_reset : bool ):
1819
1920 planes = []
@@ -22,7 +23,6 @@ def RunScript(self,
2223 all_poses_in_time .reset ()
2324 return None , None
2425
25- previous_poses = all_poses_in_time .get_last_poses ()
2626 all_poses_this_time = []
2727 for i , cloud in enumerate (i_clouds ):
2828 df_cloud = df_cvt_bindings .cvt_rhcloud_2_dfcloud (cloud )
@@ -34,23 +34,13 @@ def RunScript(self,
3434 df_points = df_cloud .get_axis_aligned_bounding_box ()
3535 df_point = (df_points [0 ] + df_points [1 ]) / 2
3636 rh_point = Rhino .Geometry .Point3d (df_point [0 ], df_point [1 ], df_point [2 ])
37- vectors = []
38- # Get the main axes of the point cloud
39- previous_pose = previous_poses [i ] if previous_poses else None
40- if previous_pose :
41- rh_previous_xDirection = Rhino .Geometry .Vector3d (previous_pose .xDirection [0 ], previous_pose .xDirection [1 ], previous_pose .xDirection [2 ])
42- rh_previous_yDirection = Rhino .Geometry .Vector3d (previous_pose .yDirection [0 ], previous_pose .yDirection [1 ], previous_pose .yDirection [2 ])
43- n_faces = all_poses_in_time .poses_per_element_dictionary [f"element_{ i } " ].n_faces
44- else :
45- rh_previous_xDirection = None
46- rh_previous_yDirection = None
47- n_faces = len (diffcheck_bindings .dfb_segmentation .DFSegmentation .segment_by_normal (df_cloud , 12 , int (len (df_cloud .points )/ 20 ), True , int (len (df_cloud .points )/ 200 ), 1 ))
4837
49- axes = df_cloud .get_principal_axes (n_faces )
38+ axes = df_cloud .get_principal_axes (3 )
39+ vectors = []
5040 for axe in axes :
5141 vectors .append (Rhino .Geometry .Vector3d (axe [0 ], axe [1 ], axe [2 ]))
5242
53- new_xDirection , new_yDirection = df_poses .select_vectors (vectors , rh_previous_xDirection , rh_previous_yDirection )
43+ new_xDirection , new_yDirection = df_poses .select_vectors (vectors , i_assembly . beams [ i ]. plane . XAxis , i_assembly . beams [ i ]. plane . YAxis )
5444
5545 pose = df_poses .DFPose (
5646 origin = [rh_point .X , rh_point .Y , rh_point .Z ],
@@ -60,6 +50,7 @@ def RunScript(self,
6050 plane = Rhino .Geometry .Plane (origin = rh_point , xDirection = new_xDirection , yDirection = new_yDirection )
6151 planes .append (plane )
6252
63- all_poses_in_time .add_step (all_poses_this_time )
53+ if i_save :
54+ all_poses_in_time .add_step (all_poses_this_time )
6455
6556 return [planes , all_poses_in_time ]
0 commit comments