Skip to content

Commit

Permalink
WIP GH
Browse files Browse the repository at this point in the history
  • Loading branch information
petrasvestartas committed Apr 26, 2024
1 parent d1a9e7e commit 17623b8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 25 deletions.
3 changes: 0 additions & 3 deletions src/rhino/gh/ToDo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/rhino/gh/cpy/closest_indexed_points/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
###############################################################################
Expand Down Expand Up @@ -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)):
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/rhino/gh/cpy/closest_lines/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)):
Expand All @@ -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
Expand Down
20 changes: 13 additions & 7 deletions src/rhino/gh/cpy/input_set/code.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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 []

Expand Down
Binary file modified src/rhino/gh/examples/7_assign_directions_and_joint_types.gh
Binary file not shown.
Binary file not shown.

0 comments on commit 17623b8

Please sign in to comment.