Grasshopper

algorithmic modeling for Rhino

I've successfully developed a script for a skin system where a horizontal plate is produced by calculating the distance between two non-linear curves in the x/y planes, creating a Planar Surface, and extruding to a certain thickness.  Unfortunately, at ~80' tall, there will be ~160 of these skin "plates".  Is there any way to take a full list of curves, and allow it to perform it on each group of 2 curves, shifting it down one value each time (using the Shift List).  I have a basic understanding of VBScript but as of yet have discovered a way to call back to the  beginning of a grasshopper function.

Views: 919

Replies to This Discussion

Hmm I don't think that you can make a loop like you are thinking, but what you could do is use a VB or C# script component. I made an example for you, showing a bit of what you can do (it's not particularly fast though).

Cheers,
Ben

(For your purposes you could 'set multiple curves' from a Curve Component and feed these as inputs...I generated the curves randomly in this example)




Here's the code:

'most of the variables are inputs to the component
'These curve arrays are created by calling a function found at the bottom of the script
Dim crvLeft() As Curve = getCrv(cpDom, wDom, dDomL, numS, dz, mind)
Dim crvRight() As Curve = getCrv(cpDom, wDom, dDomR, numS, dz, mind)

Dim Floors(numS-1) As Brep
For i As Integer = 0 To numS - 1
Dim outline() As curve = {crvLeft(i),New Line(crvLeft(i).pointatEnd, crvRight(i).pointatend).tonurbscurve,crvRight(i),New Line(crvLeft(i).pointatstart, crvRight(i).pointatstart).tonurbscurve}
Floors(i) = brep.CreateEdgeSurface(outline)
'Component_Extrude.ExtrudeBrep(brp, axLine.Direction)
Dim edge() As Curve = curve.JoinCurves(outline)
If edge.Length = 1 Then
Dim edgeSrf As surface = surface.CreateExtrusion(edge(0), New vector3d(0, 0, t))
Dim top As brep = Floors(i).duplicateBrep
top.translate(New Vector3d(0, 0, t))
Dim breps() As brep = {Floors(i),edgeSrf.tobrep,top}
breps = brep.JoinBreps(breps, 0.000001)
If breps.length = 1 Then
Floors(i) = breps(0)
End If
Else
print("error with level " & CStr(i + 1))
End If
Next

'This is just the output
floorPlates = Floors
Attachments:
Thanks for the quick response. I'll definitely hold onto your script for reference, but I'm trying to create a horizontal extrusion as bound by two vertically different curves (+ an extra 6" on one side). Is there no easy way to cycle through a list of multiple curves, shifting it one curve each time? Another option would be if there's a way to take each curve and find the nearest curve to it vertically. I've attached what I have so far to give a clearer image of what I'm trying to achieve
Attachments:
Like so?

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Attachments:
I'm still relatively new to Grasshopper so I'm actually not 100% sure what your definition is trying to achieve (I kept getting errors when trying to use it). I've posted a reply to Ben above that helps clarify what I'm trying to achieve.
Just wanted to say thanks again. I decided to consider other ways I could relate the various curves to each other without looping through a script and came up with a viable solution. At the moment it has a few issues when a surface goes beyond vertical, but is something that I think can be easily fixed by checking the distance between points on a curve or where they intersect and adjusting accordingly.
Attachments:

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service