Shingles flow

Script developed to populate free-form surfaces with overlapping irregular panels otherwise known as ‘shingles’. Sculpture project for North Scotland by biomorphis.

Call Main()
Sub Main()
Dim strSurface : strSurface = Rhino.GetObject(“Select original surface”,8)
Dim arrDomU, arrDomV
arrDomU = Rhino.SurfaceDomain(strSurface, 0)
arrDomV = Rhino.SurfaceDomain(strSurface, 1)
Dim strDivU : strDivU = Rhino.GetReal(“Please enter number of divisions in u direction”,200)
Dim strDivV : strDivV = Rhino.GetReal(“Please enter number of divisions in V direction”,20)
Dim n,t,p
Dim dblParameterU,dblParameterUGap
Dim dblParameterV
Dim dblParameterVLap
Dim arrPtU(),arrPtUOffset(),arrPtOverlap(),arrPtUGap()
Dim arrPtUV(),arrPtUVOffset(),arrPtUVOverlap(),arrPtUVGap()
Dim arrCtrPt()
Dim strLoft1,strLoft2
Dim arrObjects
Dim arrVecNorm
Dim arrKnot, arrKnotOffset,arrVectilt,arrKnotOverLap,arrKnotGap,arrKnotOffsetGap
Dim strSrfShingle,strShingleExtrudePath
Dim dblOverLap: dblOverLap = 0.2
Call Rhino.EnableRedraw(False)
For n=0 To strDivV
Dim dblVPercent: dblVPercent = ((arrDomV(1)-arrDomV(0))/strDivV)*0.3*rnd
dblParameterV=arrDomV(0)+((arrDomV(1)-arrDomV(0))/strDivV)*n + dblVPercent
dblParameterVLap=dblParameterV+((arrDomV(1)-arrDomV(0))/strDivV)*dblOverLap
For t=0 To strDivU
Dim dblUPercent : dblUPercent = (arrDomU(1)-arrDomU(0))/strDivU*0.3*rnd
dblParameterU=arrDomU(0)+((arrDomU(1)-arrDomU(0))/strDivU)*t + dblUPercent
dblParameterUGap=dblParameterU-((arrDomU(1)-arrDomU(0))/strDivU)*0.04′>>>>> gap dimension
arrKnot = Rhino.EvaluateSurface(strSurface,Array(dblParameterU,dblParameterV))
arrKnotOverLap = Rhino.EvaluateSurface(strSurface,Array(dblParameterUGap,dblParameterVLap))
arrKnotGap = Rhino.EvaluateSurface(strSurface,Array(dblParameterUGap,dblParameterV))
arrVecNorm = Rhino.SurfaceNormal(strSurface,Array(dblParameterUGap,dblParameterV))
If isarray(arrVecNorm)Then
Dim dblSlateTilt : dblSlateTilt = (10+5*rnd)
arrVectilt = Rhino.VectorScale(arrVecNorm,dblSlateTilt)
arrKnotOffset= Rhino.PointAdd(arrKnot,arrVectilt)
arrKnotOffsetGap= Rhino.PointAdd(arrKnotGap,arrVectilt)
End If
ReDim Preserve arrPtU(t)
arrPtU(t)= arrKnot
ReDim Preserve arrPtOverLap(t)
arrPtoverLap(t)= arrKnotOverLap
ReDim Preserve arrPtUOffset(t)
arrPtUOffset(t)=arrKnotOffset
ReDim Preserve arrPtUGap(t)
arrPtUGap(t)=arrKnotOffsetGap
‘Call Rhino.AddPoint(arrPtV(t))
Next
ReDim Preserve arrPtUV(n)
arrPtUV(n)=arrPtU
ReDim Preserve arrPtUVOffset(n)
arrPtUVOffset(n)=arrPtUOffset
ReDim Preserve arrPtUVOverLap(n)
arrPtUVOverLap(n) = arrPtoverLap
ReDim Preserve arrPtUVGap(n)
arrPtUVGap(n)=arrPtUGap
‘Call Rhino.AddCurve(arrPtV,2)
Next
‘———-n row of shingles surfaces———————————-
For n = 0 To (strDivV-1) Step 2
For p=0 To (strDivU-1)Step 2
strLoft1 = Rhino.AddCurve(array(arrPtUVOffset(n)(p),arrPtUVGap(n)(p+2)))
strLoft2 = Rhino.AddCurve(array(arrPtUVOverLap(n+1)(p),arrPtUVOverLap(n+1)(p+2)))
arrObjects = Array(strLoft1,strLoft2)
strSrfShingle = Rhino.AddLoftSrf(arrObjects)
strShingleExtrudePath=rhino.AddLine(arrPtUV(n)(p),arrPtUVOffset(n)(p))
Call rhino.ExtrudeSurface(strSrfShingle(0),strShingleExtrudePath)
Call Rhino.DeleteObject(strLoft1)
Call Rhino.DeleteObject(strLoft2)
Call Rhino.DeleteObjects(strSrfShingle)
Call Rhino.DeleteObject(strShingleExtrudePath)
Next
Next
‘———-n+1 row of shingles surfaces——————————–
For n = 1 To (strDivV-1) Step 2
For p=1 To (strDivU-2) Step 2
strLoft1 = Rhino.AddCurve(array(arrPtUVOffset(n)(p),arrPtUVGap(n)(p+2)))
strLoft2 = Rhino.AddCurve(array(arrPtUVOverLap(n+1)(p),arrPtUVOverLap(n+1)(p+2)))
arrObjects = Array(strLoft1,strLoft2)
strSrfShingle = Rhino.AddLoftSrf(arrObjects)
strShingleExtrudePath=rhino.AddLine(arrPtUV(n)(p),arrPtUVOffset(n)(p))
Call rhino.ExtrudeSurface(strSrfShingle(0),strShingleExtrudePath)
Call Rhino.DeleteObject(strLoft1)
Call Rhino.DeleteObject(strLoft2)
Call Rhino.DeleteObjects(strSrfShingle)
Call Rhino.DeleteObject(strShingleExtrudePath)
Next
Next
Call Rhino.HideObject(strSurface)
Call Rhino.EnableRedraw(True)
End Sub
Advertisements

3 responses to “Shingles flow

  1. I know the basics of grasshopper, but absolutely no rhinoscript. i know i should just read the primer but i want to tinker with this behemoth, it looks so exciting

    when i run this i get a error something like this:

    microsfot vbscript runtime error
    invalid use of null
    line:23
    char:0

    please help

    • Try replacing the lines (8 and 9):

      Dim strDivU : strDivU = Rhino.GetReal(“Please enter number of divisions in u direction”,200)
      Dim strDivV : strDivV = Rhino.GetReal(“Please enter number of divisions in V direction”,20)

      with:

      Dim strDivU : strDivU = Rhino.GetReal(Please enter number of divisions in u direction,200)
      If isnull (strDivU) Then Exit Sub
      Dim strDivV : strDivV = Rhino.GetReal(Please enter number of divisions in V direction,20)
      If isnull (strDivV) Then Exit Sub

  2. When I try to run this script it gives me multiple errors, saying the code is not correct. “unterminated lines” and other errors. is there a way to upload a working script? thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s