Skip to content

Commit de7b580

Browse files
fix: add ghpythonlib. to the overrides of mypy
1 parent f7016b4 commit de7b580

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ module = [
2020
"GH_IO.*",
2121
"clr.*",
2222
"diffcheck_bindings",
23-
"diffCheck.diffcheck_bindings"
23+
"diffCheck.diffcheck_bindings",
24+
"ghpythonlib.*"
2425
]
2526
ignore_missing_imports = true
2627

src/gh/diffCheck/diffCheck/df_poses.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
from scriptcontext import sticky as rh_sticky_dict
2+
import ghpythonlib.treehelpers as th
3+
import Rhino
4+
25
import json
36
from 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
1527
class 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

87111
def compute_dot_product(v1, v2):
88112
"""

0 commit comments

Comments
 (0)