algorithmic modeling for Rhino
Hooray! I've finally got a basic sloping script up and running. It works fine with polylines.
Hiccups:
What I'd LOVE to see in GH (in a VB component), would be a way to take input as a bunch of lines like a tree (see attached file), and create the sloping for them. (see same attached file)
Would someone care to take a crack at it?
-Suthern
Tags:
Oops, here's my vb code (from the Script Editor):
Private Sub RunScript(ByVal C As Polyline, ByVal N As Object, ByVal P As List(Of Point3d), ByRef A As Object, ByRef Dists As Object)
Dim crvMainLine
Dim arrPts, i, x, y, decBase
Dim decPrev, tmpLength
Dim new_pts As New List(Of Point3D)
Dim count As Integer
count = P.Count() - 1
Dim decRatio, decRad
decRad = 180 / 3.14159265
crvMainLine = C
decRatio = N
'arrPts = Rhino.CurveEditPoints(crvMainLine)
arrPts = P
decBase = arrPts(0).z
decPrev = 0
' Get the horizontal lengths (runs)
For i = 0 To count
'Declare a new point and copy pt(i) value
Dim temp_pt As New Rhino.Geometry.Point3d(arrPts(i).x, arrPts(i).y, arrPts(i).z)
If i = 0 Then
'arrPts(i)(2) = decBase
temp_pt.z = decBase
Else
x = arrPts(i).x - arrPts(i - 1).x
y = arrPts(i).y - arrPts(i - 1).y
tmpLength = System.Math.Sqrt((x * x) + (y * y))
'tmpLength = Rhino.Distance(arrPts(i), arrPts(i - 1))
temp_pt.z = decBase + ( tmpLength / decRatio ) + decPrev
End If
'decPrev = arrPts(i)(2) - decBase
decPrev = temp_pt.z - decBase
new_pts.Add(temp_pt)
Next
'Set return point to the new list of points
A = new_pts
End Sub
I've solved how to create polylines, but ran into a ton of snags using lists of curves. grr. why cant I do list.add(newCurveObject) like I can with lists of point3d's? anyway...
Right now I'm at the point where I can't figure out how to do 'recursive' actions with Grasshopper. I've included my Rhino file and rather simple Grasshopper definition in hopes that someone might look at it and give me a few pointers. :)
Here's the latest definition which is almost good to go. It's pruning that branches that shouldn't be pruned.
I'm sure there would a faster way to do this using the datatree in grasshopper, and if anyone wants to tackle converting it, feel free! This method uses VB lists for most of the data storage, and seems to work. Almost. :)
Sweet, I've solved that problem. For some reason removeAt was not taking an index number properly.
It now works exactly as I want it to!
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by