55
66import System
77
8+ import diffCheck .df_geometries
89import numpy
910
1011
1112class DFPoseComparison (component ):
1213 def RunScript (self ,
13- i_CAD_poses : System . Collections . Generic . List [ Rhino . Geometry . Plane ] ,
14+ i_assembly : diffCheck . df_geometries . DFAssembly ,
1415 i_measured_poses : System .Collections .Generic .List [Rhino .Geometry .Plane ]):
1516
16- if len (i_CAD_poses ) != len (i_measured_poses ):
17+ if len (i_assembly . beams ) != len (i_measured_poses ):
1718 ghenv .Component .Message = "evaluation during assembly" # noqa: F821
1819 else :
1920 ghenv .Component .Message = "evaluation of completed assembly" # noqa: F821
2021
22+ CAD_poses = [beam .plane for beam in i_assembly .beams ]
23+
2124 o_distances = []
2225 o_angles = []
2326 o_transforms_cad_to_measured = []
2427 # Compare the origins
2528 # measure the distance between the origins of the CAD pose and the measured pose and output this in the component
2629 for i in range (len (i_measured_poses )):
27- cad_origin = i_CAD_poses [i ].Origin
30+ cad_origin = CAD_poses [i ].Origin
2831 measured_origin = i_measured_poses [i ].Origin
2932 distance = cad_origin .DistanceTo (measured_origin )
3033 o_distances .append (distance )
3134
3235 # Compare the orientations using the formula: $$ \theta = \arccos\left(\frac{\text{trace}(R_{\text{pred}}^T R_{\text{meas}}) - 1}{2}\right) $$
33- transform_o_to_cad = Rhino .Geometry .Transform .PlaneToPlane (Rhino .Geometry .Plane .WorldXY , i_CAD_poses [i ])
36+ transform_o_to_cad = Rhino .Geometry .Transform .PlaneToPlane (Rhino .Geometry .Plane .WorldXY , CAD_poses [i ])
3437 transform_o_to_measured = Rhino .Geometry .Transform .PlaneToPlane (Rhino .Geometry .Plane .WorldXY , i_measured_poses [i ])
3538 np_transform_o_to_cad = numpy .array (transform_o_to_cad .ToDoubleArray (rowDominant = True )).reshape ((4 , 4 ))
3639 np_transform_o_to_measured = numpy .array (transform_o_to_measured .ToDoubleArray (rowDominant = True )).reshape ((4 , 4 ))
@@ -42,7 +45,7 @@ def RunScript(self,
4245 o_angles .append (theta )
4346
4447 # Compute the transformation matrix between the CAD pose and the measured pose
45- transform_cad_to_measured = Rhino .Geometry .Transform .PlaneToPlane (i_CAD_poses [i ], i_measured_poses [i ])
48+ transform_cad_to_measured = Rhino .Geometry .Transform .PlaneToPlane (CAD_poses [i ], i_measured_poses [i ])
4649 o_transforms_cad_to_measured .append (transform_cad_to_measured )
4750
4851 return [o_distances , o_angles , o_transforms_cad_to_measured ]
0 commit comments