diff --git a/src/rhino/gh/ToDo.md b/src/rhino/gh/ToDo.md index c7427f64f..b7f571ceb 100644 --- a/src/rhino/gh/ToDo.md +++ b/src/rhino/gh/ToDo.md @@ -7,15 +7,12 @@ beam_volume box_wall chevron chevron_plates -closest_indexed_points -closest_lines connection_zones connectors custom_joints cut_group folding_diamonds input_get -input_set joints line_volume orient_data diff --git a/src/rhino/gh/cpy/closest_indexed_points/code.py b/src/rhino/gh/cpy/closest_indexed_points/code.py index 0cdb2b1ea..dd3711034 100644 --- a/src/rhino/gh/cpy/closest_indexed_points/code.py +++ b/src/rhino/gh/cpy/closest_indexed_points/code.py @@ -27,7 +27,10 @@ class MyComponent(component): - def RunScript(self, _polylines, _points, _joint_types): + def RunScript(self, + _polylines: Grasshopper.DataTree[Rhino.Geometry.Curve], + _points: Grasshopper.DataTree[Rhino.Geometry.Point3d], + _joint_types: Grasshopper.DataTree[int]): ############################################################################### # Input ############################################################################### @@ -64,9 +67,8 @@ def RunScript(self, _polylines, _points, _joint_types): ############################################################################### # convert element polylines to a flattened dictionary: - segments_dictionary = ( - {} - ) # stores ids e.g. int , [element_int,bottom_or_top_polyline_int,edge,int, bounding_box, hit_count, point_id] + segments_dictionary = {} + # stores ids e.g. int , [element_int,bottom_or_top_polyline_int,edge,int, bounding_box, hit_count, point_id] joint_types = [] count = 0 for i in range(len(polylines)): @@ -75,9 +77,7 @@ def RunScript(self, _polylines, _points, _joint_types): for k in range(polylines[i][j].SegmentCount): bbox = polylines[i][j].SegmentAt(k).BoundingBox bbox.Inflate(0.02) - segments_dictionary.Add( - count, [i, j, k, bbox, polylines[i][j].SegmentAt(k)] - ) + segments_dictionary[count] = [i, j, k, bbox, polylines[i][j].SegmentAt(k)] count = count + 1 # create a tree diff --git a/src/rhino/gh/cpy/closest_lines/code.py b/src/rhino/gh/cpy/closest_lines/code.py index fa1193ec0..46e4e8b4b 100644 --- a/src/rhino/gh/cpy/closest_lines/code.py +++ b/src/rhino/gh/cpy/closest_lines/code.py @@ -6,7 +6,7 @@ __author__ = "petra" __version__ = "2023.04.04" - +import System import Rhino.Geometry from Rhino.Geometry import RTree from Rhino.Geometry import BoundingBox @@ -20,7 +20,9 @@ class MyComponent(component): - def RunScript(self, _polylines, _lines): + def RunScript(self, + _polylines: Grasshopper.DataTree[Rhino.Geometry.Curve], + _lines: Grasshopper.DataTree[Rhino.Geometry.Line]): """Provides a scripting component. Inputs: x: The x script variable @@ -57,9 +59,8 @@ def RunScript(self, _polylines, _lines): ############################################################################### # convert element polylines to a flattened dictionary: - segments_dictionary = ( - {} - ) # stores ids e.g. int , [element_int,bottom_or_top_polyline_int,edge,int, bounding_box, hit_count, point_id] + segments_dictionary = {} + # stores ids e.g. int , [element_int,bottom_or_top_polyline_int,edge,int, bounding_box, hit_count, point_id] vectors = [] count = 0 for i in range(len(polylines)): @@ -68,9 +69,8 @@ def RunScript(self, _polylines, _lines): for k in range(polylines[i][j].SegmentCount): bbox = polylines[i][j].SegmentAt(k).BoundingBox bbox.Inflate(0.02) - segments_dictionary.Add( - count, [i, j, k, bbox, polylines[i][j].SegmentAt(k)] - ) + segments_dictionary[count]= [i, j, k, bbox, polylines[i][j].SegmentAt(k)] + count = count + 1 # create a tree diff --git a/src/rhino/gh/cpy/input_set/code.py b/src/rhino/gh/cpy/input_set/code.py index f647c36f5..7816ff91e 100644 --- a/src/rhino/gh/cpy/input_set/code.py +++ b/src/rhino/gh/cpy/input_set/code.py @@ -1,3 +1,4 @@ +"""combine different data sets into one list for a faster data transder between grasshopper wires""" from ghpythonlib.componentbase import executingcomponent as component import Grasshopper, GhPython __author__ = "petras" @@ -36,21 +37,26 @@ def get_plane(self, _polyline, _orientation_point): - def RunScript(self, _plines, _insertion_vectors, _joints_per_face, _three_valence, _adjacency): + def RunScript(self, + _polylines: Grasshopper.DataTree[Rhino.Geometry.Polyline], + _vectors: Grasshopper.DataTree[Rhino.Geometry.Vector3d], + _joint_types: Grasshopper.DataTree[int], + _three_valence: Grasshopper.DataTree[int], + _adjacency: Grasshopper.DataTree[int]): plines = [] planes = [] - if( _plines.DataCount > 0): - for i in range(_plines.BranchCount): - plines.append(_plines.Branch(i)) + if( _polylines.DataCount > 0): + for i in range(_polylines.BranchCount): + plines.append(_polylines.Branch(i)) # create planes for orientation - planes.append(self.get_plane(_plines.Branch(i)[0],_plines.Branch(i)[1][0])) + planes.append(self.get_plane(_polylines.Branch(i)[0],_polylines.Branch(i)[1][0])) - insertion_vectors = th.tree_to_list(_insertion_vectors) if _insertion_vectors.DataCount > 0 else [] - joints_per_face = th.tree_to_list(_joints_per_face) if _joints_per_face.DataCount > 0 else [] + insertion_vectors = th.tree_to_list(_vectors) if _vectors.DataCount > 0 else [] + joints_per_face = th.tree_to_list(_joint_types) if _joint_types.DataCount > 0 else [] three_valence = th.tree_to_list(_three_valence) if _three_valence.DataCount > 0 else [] adjacency = th.tree_to_list(_adjacency) if _adjacency.DataCount > 0 else [] diff --git a/src/rhino/gh/examples/7_assign_directions_and_joint_types.gh b/src/rhino/gh/examples/7_assign_directions_and_joint_types.gh index 0308a9129..bcb10855a 100644 Binary files a/src/rhino/gh/examples/7_assign_directions_and_joint_types.gh and b/src/rhino/gh/examples/7_assign_directions_and_joint_types.gh differ diff --git a/src/rhino/gh/examples/7_assign_directions_and_joint_types2.gh b/src/rhino/gh/examples/7_assign_directions_and_joint_types2.gh new file mode 100644 index 000000000..fbe03a375 Binary files /dev/null and b/src/rhino/gh/examples/7_assign_directions_and_joint_types2.gh differ