Rhinoscript Etude
I made this little script a few years ago.
It tessellates a nurbs surface in several layers, and extrudes one of the layer with another parameter.
It can be applied to generate a parametric building facade for specific site condition.
Printed out with resin 3d printer.
Below is the complete script.
Option Explicit ' 20080507 Chris Kim Call Panel1() Sub Panel1() Dim idSurface : idSurface = Rhino.GetObject("Surface to frame", 8, True, True) If IsNull(idSurface) Then Exit Sub Dim intCountU : intCountU = Rhino.GetInteger("Number of iterations per direction", 10, 2) If IsNull(intCountU) Then Exit Sub Dim intCountV : intCountV = Rhino.GetInteger("Number of iterations per direction", 10, 2) If IsNull(intCountV) Then Exit Sub Dim intTessel : intTessel = Rhino.GetInteger("maximum degree of tesselation", 3, 2,10) If IsNull(intTessel) Then Exit Sub Dim arrSurfaceDmU : arrSurfaceDmU = Rhino.SurfaceDomain (idSurface, 0) Dim arrSurfaceDmV : arrSurfaceDmV = Rhino.SurfaceDomain (idSurface, 1) ' common vars Dim arrQuadPanelPoints(4), arrCenterOfPanel Dim currentPlane, strCurrentQuadPanel Dim recXspread,recYspread Dim strSullivan2, strSullivan5, strSullivan7 Dim tempScale, arrTempPt Dim arrStrTessel2Quads(3),arrTessel2Points Dim i,j,k,l,m,n ' var for sullivan 2 process Dim dblExtrusion Dim arrProcess2Pt1 : arrProcess2Pt1 = Rhino.GetPointOnSurface (idSurface,"pick light effect point no.1 (positive louvers)") Dim arrProcess2Pt1_2 : arrProcess2Pt1_2 = Rhino.GetPointOnSurface (idSurface,"effect area for point no.1") Dim dblProc2Dist1 : dblProc2Dist1 = Rhino.Distance (arrProcess2Pt1, arrProcess2Pt1_2) Dim dblCurrentProc2Dist1 Dim arrProcess2Pt2 : arrProcess2Pt2 = Rhino.GetPointOnSurface (idSurface,"pick light effect point no.2 (negative louvers)") Dim arrProcess2Pt2_2 : arrProcess2Pt2_2 = Rhino.GetPointOnSurface (idSurface,"effect area for point no.2") Dim dblProc2Dist2 : dblProc2Dist2 = Rhino.Distance (arrProcess2Pt2, arrProcess2Pt2_2) Dim dblCurrentProc2Dist2 ' Layers Call Rhino.AddLayer ("panels_quad_t1",RGB(0,0,255),vbTrue) For i = 2 to intTessel Call Rhino.AddLayer ("panels_quad_t" & i, RGB(0,255,255)) Next Call Rhino.AddLayer ("Sullivan2_result") '--------------------------------------------- ' ' first paneling ' '--------------------------------------------- For i = 0 to arrSurfaceDmU(1)-arrSurfaceDmU(1)/intCountU Step arrSurfaceDmU(1)/intCountU For j = 0 to arrSurfaceDmV(1)-arrSurfaceDmV(1)/intCountV Step arrSurfaceDmV(1)/intCountV Call Rhino.EnableRedraw(False) arrQuadPanelPoints(0) = Rhino.SurfaceEvaluate (idSurface, Array(i,j), 1)(0) arrQuadPanelPoints(1) = Rhino.SurfaceEvaluate (idSurface, Array(i+arrSurfaceDmU(1)/intCountU,j), 1)(0) arrQuadPanelPoints(2) = Rhino.SurfaceEvaluate (idSurface, Array(i+arrSurfaceDmU(1)/intCountU,j+arrSurfaceDmV(1)/intCountV), 1)(0) arrQuadPanelPoints(3) = Rhino.SurfaceEvaluate (idSurface, Array(i,j+arrSurfaceDmV(1)/intCountV), 1)(0) arrQuadPanelPoints(4) = arrQuadPanelPoints(0) 'current quad panel strCurrentQuadPanel = Rhino.AddPolyline (arrQuadPanelPoints) 'center point of panel arrCenterOfPanel = MidPoint(arrQuadPanelPoints(1),arrQuadPanelPoints(3)) Call Rhino.ObjectLayer (strCurrentQuadPanel, "panels_quad_t1") Call Rhino.EnableRedraw(True) Next Next '------------------------------------------------ ' ' further Tessellation ' '------------------------------------------------- For j = 2 to intTessel Dim arrSelectedQuads Dim arrTessellated arrSelectedQuads = Rhino.ObjectsByLayer ("panels_quad_t" & j-1) 'select panels from previous level Rhino.Print "panels_quad_t" & j-1 & " panels are being tesselated" If IsArray(arrSelectedQuads) Then For k = 0 to UBound(arrSelectedQuads) Call Rhino.EnableRedraw(False) Dim arrCurrentQuadPanelPoints Dim dblCurrentSrfGrade dblCurrentSrfGrade = GetGradeInQuad(idSurface, arrSelectedQuads(k)) If dblCurrentSrfGrade > 90/intTessel*(j-1) Then arrCurrentQuadPanelPoints = Rhino.PolylineVertices (arrSelectedQuads(k)) arrTessellated = TessellateQuad(arrCurrentQuadPanelPoints) Call Rhino.ObjectLayer (Rhino.AddPolyline (arrTessellated(0)), "panels_quad_t" & j) Call Rhino.ObjectLayer (Rhino.AddPolyline (arrTessellated(1)), "panels_quad_t" & j) Call Rhino.ObjectLayer (Rhino.AddPolyline (arrTessellated(2)), "panels_quad_t" & j) Call Rhino.ObjectLayer (Rhino.AddPolyline (arrTessellated(3)), "panels_quad_t" & j) Rhino.DeleteObject (arrSelectedQuads(k)) End If Call Rhino.EnableRedraw(True) Next End If Next '------------------------------------------------ ' ' Layer purge ' '------------------------------------------------- For l = 0 to intTessel Dim arrTempCheckLayer arrTempCheckLayer = Rhino.ObjectsByLayer ("panels_quad_t" & l) If Not IsArray(arrTempCheckLayer) Then Rhino.DeleteLayer("panels_quad_t" & l) Rhino.Print "panels_quad_t" & l & " is deleted" End If Next '------------------------------------------------ ' ' process for ' sullivan ornament element No.2 ' '------------------------------------------------- For m = 1 to intTessel Dim arrSullivan2 arrSelectedQuads = Rhino.ObjectsByLayer ("panels_quad_t" & m) If IsArray(arrSelectedQuads) Then Rhino.Print "Extruding level " & m For n = 0 to UBound(arrSelectedQuads) arrCenterOfPanel = GetQuadCenter(Rhino.PolylineVertices (arrSelectedQuads(n))) 'set condition dblCurrentProc2Dist1 = Rhino.Distance(arrProcess2Pt1,arrCenterOfPanel) dblCurrentProc2Dist2 = Rhino.Distance(arrProcess2Pt2,arrCenterOfPanel) dblExtrusion = 0 If dblCurrentProc2Dist1 >= dblCurrentProc2Dist2 Then ' Panel is closer to point 1 If dblCurrentProc2Dist2
Complete script download
Categorised as: Generative design
Hi Chris
I am fairly new to scripting and just trying out a few things to get familiar with it and testing a few scripts people wrote and posted online. So I found yours and it looks very interesting. I am trying to work it and understand it but unfortunately I always get stuck already on line 73 and I don’t understand what I am missing. It must be because I don’t understand which are the points to choose for positive and negative louvers?
I would very grateful if you could explain your script a little bit to me.
Hope to hearing back from you.
Best,
Julia
Hi,
I was wondering if you could help me out. I’m teaching a course in scripting down in Guatemala. I wanted to show your script as an example but cant seem to get the full script. Could you provide it?
thanks,
AB
Hi, sorry about late reply.
I’ve uploaded complete script for you.
You should be able to download it from the link at the bottom of this post.
This script is really old and I had to dig up from my disk.
You can achieve the same result with much better control over the parameters with Grasshopper plugin.
But, I guess writing your own script is always fun to do.
Thanks,
Chris
Hi Chris,
The script is no longer available for download. Could you upload it again?
Thank you,
Hey, I would love to use this script for a school project, would you mind posting it again to the link?