11from scriptcontext import sticky as rh_sticky_dict
2+ import ghpythonlib .treehelpers as th
3+ import Rhino
4+
25import json
36from dataclasses import dataclass , field
47
@@ -11,6 +14,15 @@ class DFPose:
1114 xDirection : list
1215 yDirection : list
1316
17+ def to_rh_plane (self ):
18+ """
19+ Convert the pose to a Rhino Plane object.
20+ """
21+ origin = Rhino .Geometry .Point3d (self .origin [0 ], self .origin [1 ], self .origin [2 ])
22+ xDirection = Rhino .Geometry .Vector3d (self .xDirection [0 ], self .xDirection [1 ], self .xDirection [2 ])
23+ yDirection = Rhino .Geometry .Vector3d (self .yDirection [0 ], self .yDirection [1 ], self .yDirection [2 ])
24+ return Rhino .Geometry .Plane (origin , xDirection , yDirection )
25+
1426@dataclass
1527class DFPosesBeam :
1628 """
@@ -83,6 +95,18 @@ def save(self, file_path: str):
8395 with open (file_path , 'w' ) as f :
8496 json .dump (self .poses_per_element_dictionary , f , default = lambda o : o .__dict__ , indent = 4 )
8597
98+ def to_gh_tree (self ):
99+ """
100+ Convert the assembly poses to a Grasshopper tree structure.
101+ """
102+ list_of_poses = []
103+ for element , poses in self .poses_per_element_dictionary .items ():
104+ list_of_pose_of_element = []
105+ for pose in poses .poses_dictionnary .values ():
106+ list_of_pose_of_element .append (pose .to_rh_plane () if pose is not None else None )
107+ list_of_poses .append (list_of_pose_of_element )
108+ return th .list_to_tree (list_of_poses )
109+
86110
87111def compute_dot_product (v1 , v2 ):
88112 """
0 commit comments