Skin panel prototype 1

'skin panel prototype 'joshua vermillion '8 june 2006

'In: Surface, U and V divisions, apperture height 'Out: Skin panel prototypes created as developable surfaces, ready to be unrolled and laser cut

'The skin panels and the script which generates the panels forms and shapes were devised by me 'Most of the upfront scripting, dealing with surface redescription and surface tiling was lifted 'from a script written by Andrew Kudless: materialsystems.org

Option Explicit

Sub skin01

Dim sourceSurface, uDiv, vDiv, height, grid Dim uStep, vStep Dim uVal, vVal Dim i, j   Dim tilePoints(3) Dim apexData, apexPoint1, apexPoint2, apexPoint3, apexPoint4, apexPoint5, apexPoint6 Dim apexPoint7, apexPoint8, apexPoint9, apexPoint10, apexPoint11, apexPoint12 Dim arrPoint

'Prompt user for input data sourceSurface = Rhino.GetObject("Select a surface to populate", 8)

uDiv = Rhino.GetInteger("Enter the number of divisions in the U direction", 4, 1)

vDiv = Rhino.GetInteger("Enter the number of divisions in the V direction", 20, 1)

height = Rhino.GetReal("Enter a height for the spaceframe") 'End input data

'To simplify the script, the surface is reparameterized to go from 0 to 1 in both directions Rhino.SelectObject sourceSurface Rhino.Command "Reparameterize 0 1 0 1 "

'Redimension the arrays that will hold all the values of U and V to the number of tiles in each direction ReDim uVal(uDiv) ReDim vVal(vDiv) ReDim apexPoint1 ((uDiv-1),(vDiv-1)) ReDim apexPoint2 ((uDiv-1),(vDiv-1)) ReDim apexPoint3 ((uDiv-1),(vDiv-1)) ReDim apexPoint4 ((uDiv-1),(vDiv-1)) ReDim apexPoint5 ((uDiv-1),(vDiv-1)) ReDim apexPoint6 ((uDiv-1),(vDiv-1)) ReDim apexPoint7 ((uDiv-1),(vDiv-1)) ReDim apexPoint8 ((uDiv-1),(vDiv-1)) ReDim apexPoint9 ((uDiv-1),(vDiv-1)) ReDim apexPoint10 ((uDiv-1),(vDiv-1)) ReDim apexPoint11 ((uDiv-1),(vDiv-1)) ReDim apexPoint12 ((uDiv-1),(vDiv-1))

'Find the step value, i.e. the distance between tiles in each direction. (note: this is not the euclidian distance, it is the distance measured in UV space) uStep = 1/uDiv vStep = 1/vDiv

'Fill the arrays with the actual values of U and V at each step For i = 0 To uDiv uVal(i) = i * uStep Rhino.Print "uVal(" & i & "):" & uVal(i) Next

For i = 0 To vDiv vVal(i) = i * vStep Rhino.Print "vVal(" & i & "):" & vVal(i) Next

'Disable Rhino from redrawing the views during the tile construction to speed things up   'Rhino.EnableRedraw vbFalse Rhino.Print "Constructing spaceframe..."

'Start looping through each u and v division and create the tile within

For i = 0 To uDiv-1 For j = 0 To vDiv-1 Dim a1, b1, d1, e1, f1, h1, k1, l1, m1, n1, o1, p1, q1           Dim a2, b2, d2, e2, f2, h2, k2, l2, m2, n2, o2, p2, q2            'Find the 3D coordinate for each of the 4 corners of the tile using the UV coordinates as input tilePoints(0) = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i), vVal(j))) tilePoints(1) = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i+1), vVal(j))) tilePoints(2) = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i+1), vVal(j+1))) tilePoints(3) = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i), vVal(j+1)))

a1 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i), vVal(j)+(vVal(1)/2))) b1 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+(uVal(1)/5), vVal(j)+(vVal(1)/2))) d1 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+(uVal(1)*.8), vVal(j)+(vVal(1)/2))) e1 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+uVal(1), vVal(j)+(vVal(1)/2))) f1 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+uVal(1), vVal(j))) h1 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+(uVal(1)/2), vVal(j))) k1 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i), vVal(j))) l1 = Rhino.SurfaceCurvature(sourceSurface, Array(uVal(i)+(uVal(1)/2), vVal(j)+(vVal(1)/3))) n1 = Rhino.SurfaceCurvature(sourceSurface, Array(uVal(i)+(uVal(1)/5), vVal(j)+(vVal(1)/6))) p1 = Rhino.SurfaceCurvature(sourceSurface, Array(uVal(i)+(uVal(1)*.8), vVal(j)+(vVal(1)/6))) a2 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i), vVal(j)+(vVal(1)/2))) b2 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+(uVal(1)/5), vVal(j)+(vVal(1)/2))) d2 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+(uVal(1)*.8), vVal(j)+(vVal(1)/2))) e2 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+uVal(1), vVal(j)+(vVal(1)/2))) f2 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+uVal(1), vVal(j)+vVal(1))) h2 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+(uVal(1)/2), vVal(j)+vVal(1))) k2 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i), vVal(j)+vVal(1))) l2 = Rhino.SurfaceCurvature(sourceSurface, Array(uVal(i)+(uVal(1)/2), vVal(j)+(vVal(1)*.67))) n2 = Rhino.SurfaceCurvature(sourceSurface, Array(uVal(i)+(uVal(1)/5), vVal(j)+(vVal(1)*.83))) p2 = Rhino.SurfaceCurvature(sourceSurface, Array(uVal(i)+(uVal(1)*.8), vVal(j)+(vVal(1)*.83))) Dim l1curvature, n1curvature, p1curvature Dim l2curvature, n2curvature, p2curvature l1curvature = l1(2) n1curvature = n1(2) p1curvature = p1(2) l2curvature = l2(2) n2curvature = n2(2) p2curvature = p2(2) apexPoint1(i,j) = offsetCalc(l1, height*l1curvature) apexPoint2(i,j) = offsetCalc(n1, height*n1curvature) apexPoint3(i,j) = offsetCalc(p1, height*p1curvature) apexPoint4(i,j) = offsetCalc(l2, height*l2curvature) apexPoint5(i,j) = offsetCalc(n2, height*n2curvature) apexPoint6(i,j) = offsetCalc(p2, height*p2curvature) Dim ak1, bk1, bo1, bh1, mh1, dh1, dq1, df1, ef1 Dim ab1, bm1, md1, ko1, oh1, hq1, fq1, de1 Dim ak2, bk2, bo2, bh2, mh2, dh2, dq2, df2, ef2 Dim ab2, bm2, md2, ko2, oh2, hq2, fq2, de2 ak1 = Rhino.AddLine(a1, k1) bk1 = Rhino.AddLine(b1, k1) bo1 = Rhino.AddLine(b1, apexPoint2(i,j)) bh1 = Rhino.AddLine(b1, h1) mh1 = Rhino.AddLine(apexPoint1(i,j), h1) dh1 = Rhino.AddLine(d1, h1) dq1 = Rhino.AddLine(d1, apexPoint3(i,j)) df1 = Rhino.AddLine(d1, f1) ef1 = Rhino.AddLine(e1, f1) ab1 = Rhino.AddLine(a1, b1) bm1 = Rhino.AddLine(b1, apexPoint1(i,j)) md1 = Rhino.AddLine(apexPoint1(i,j), d1) ko1 = Rhino.AddLine(k1, apexPoint2(i,j)) oh1 = Rhino.AddLine(apexPoint2(i,j), h1) hq1 = Rhino.AddLine(h1, apexPoint3(i,j)) fq1 = Rhino.AddLine(f1, apexPoint3(i,j)) de1 = Rhino.AddLine(d1, e1) ak2 = Rhino.AddLine(a2, k2) bk2 = Rhino.AddLine(b2, k2) bo2 = Rhino.AddLine(b2, apexPoint5(i,j)) bh2 = Rhino.AddLine(b2, h2) mh2 = Rhino.AddLine(apexPoint4(i,j), h2) dh2 = Rhino.AddLine(d2, h2) dq2 = Rhino.AddLine(d2, apexPoint6(i,j)) df2 = Rhino.AddLine(d2, f2) ef2 = Rhino.AddLine(e2, f2) ab2 = Rhino.AddLine(a2, b2) bm2 = Rhino.AddLine(b2, apexPoint4(i,j)) md2 = Rhino.AddLine(apexPoint4(i,j), d2) ko2 = Rhino.AddLine(k2, apexPoint5(i,j)) oh2 = Rhino.AddLine(apexPoint5(i,j), h2) hq2 = Rhino.AddLine(h2, apexPoint6(i,j)) fq2 = Rhino.AddLine(f2, apexPoint6(i,j)) de2 = Rhino.AddLine(d2, e2) Dim arrObjects1, arrObjects2 Dim arrabk1, arrbko1, arrbho1, arrbhm1, arrdmh1, arrdhq1, arrdfq1, arrdef1 Dim arrabk2, arrbko2, arrbho2, arrbhm2, arrdmh2, arrdhq2, arrdfq2, arrdef2 Dim abk1, bko1, bho1, bhm1, dmh1, dhq1, dfq1, def1 Dim abk2, bko2, bho2, bhm2, dmh2, dhq2, dfq2, def2 arrabk1 = Array(ak1, bk1, ab1) arrbko1 = Array(bk1, bo1, ko1) arrbho1 = Array(bo1, bh1, oh1) arrbhm1 = Array(bh1, bm1, mh1) arrdmh1 = Array(dh1, md1, mh1) arrdhq1 = Array(dh1, dq1, hq1) arrdfq1 = Array(dq1, df1, fq1) arrdef1 = Array(df1, de1, ef1) arrabk2 = Array(ak2, bk2, ab2) arrbko2 = Array(bk2, bo2, ko2) arrbho2 = Array(bo2, bh2, oh2) arrbhm2 = Array(bh2, bm2, mh2) arrdmh2 = Array(dh2, md2, mh2) arrdhq2 = Array(dh2, dq2, hq2) arrdfq2 = Array(dq2, df2, fq2) arrdef2 = Array(df2, de2, ef2) abk1 = Rhino.AddPlanarSrf(arrabk1) bko1 = Rhino.AddPlanarSrf(arrbko1) bho1 = Rhino.AddPlanarSrf(arrbho1) bhm1 = Rhino.AddPlanarSrf(arrbhm1) dmh1 = Rhino.AddPlanarSrf(arrdmh1) dhq1 = Rhino.AddPlanarSrf(arrdhq1) dfq1 = Rhino.AddPlanarSrf(arrdfq1) def1 = Rhino.AddPlanarSrf(arrdef1) abk2 = Rhino.AddPlanarSrf(arrabk2) bko2 = Rhino.AddPlanarSrf(arrbko2) bho2 = Rhino.AddPlanarSrf(arrbho2) bhm2 = Rhino.AddPlanarSrf(arrbhm2) dmh2 = Rhino.AddPlanarSrf(arrdmh2) dhq2 = Rhino.AddPlanarSrf(arrdhq2) dfq2 = Rhino.AddPlanarSrf(arrdfq2) def2 = Rhino.AddPlanarSrf(arrdef2) Dim strSurface1, strSurface2 arrObjects1 = Array(abk1, bko1, bho1, bhm1, dmh1, dhq1, dfq1, def1) 'strSurface1 = Rhino.JoinSurfaces(arrObjects1, True) arrObjects2 = Array(abk2, bko2, bho2, bhm2, dmh2, dhq2, dfq2, def2) 'strSurface2 = Rhino.JoinSurfaces(arrObjects2, True) If (j = vDiv-1) Then i = i+1 End If

Next Next

For i = 0 To uDiv-1 For j = 0 To vDiv-1 Dim a3, b3, c3, d3, e3, f3, g3, h3, k3, l3           Dim a4, b4, c4, d4, e4, f4, g4, h4, k4, l4            If (j = 0) Then i = i+1 End If           'Find the 3D coordinate for each of the 4 corners of the tile using the UV coordinates as input tilePoints(0) = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i), vVal(j))) tilePoints(1) = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i+1), vVal(j))) tilePoints(2) = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i+1), vVal(j+1))) tilePoints(3) = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i), vVal(j+1)))

a3 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i), vVal(j)+(vVal(1)/2))) b3 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+(uVal(1)/2), vVal(j)+(vVal(1)/2))) c3 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+uVal(1), vVal(j)+(vVal(1)/2))) d3 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+uVal(1), vVal(j))) e3 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+(uVal(1)*.8), vVal(j))) f3 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+(uVal(1)/5), vVal(j))) g3 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i), vVal(j))) h3 = Rhino.SurfaceCurvature(sourceSurface, Array(uVal(i)+(uVal(1)/2), vVal(j)+(vVal(1)/6))) k3 = Rhino.SurfaceCurvature(sourceSurface, Array(uVal(i)+(uVal(1)/5), vVal(j)+(vVal(1)/3))) l3 = Rhino.SurfaceCurvature(sourceSurface, Array(uVal(i)+(uVal(1)*.8), vVal(j)+(vVal(1)/3))) a4 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i), vVal(j)+(vVal(1)/2))) b4 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+(uVal(1)/2), vVal(j)+(vVal(1)/2))) c4 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+uVal(1), vVal(j)+(vVal(1)/2))) d4 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+uVal(1), vVal(j)+vVal(1))) e4 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+(uVal(1)*.8), vVal(j)+vVal(1))) f4 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+(uVal(1)/5), vVal(j)+vVal(1))) g4 = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i), vVal(j)+vVal(1))) h4 = Rhino.SurfaceCurvature(sourceSurface, Array(uVal(i)+(uVal(1)/2), vVal(j)+(vVal(1)*.83))) k4 = Rhino.SurfaceCurvature(sourceSurface, Array(uVal(i)+(uVal(1)/5), vVal(j)+(vVal(1)*.67))) l4 = Rhino.SurfaceCurvature(sourceSurface, Array(uVal(i)+(uVal(1)*.8), vVal(j)+(vVal(1)*.67))) Dim h3curvature, k3curvature, l3curvature Dim h4curvature, k4curvature, l4curvature h3curvature = h3(2) k3curvature = k3(2) l3curvature = l3(2) h4curvature = h4(2) k4curvature = k4(2) l4curvature = l4(2) apexPoint7(i,j) = offsetCalc(h3, height*h3curvature) apexPoint8(i,j) = offsetCalc(k3, height*k3curvature) apexPoint9(i,j) = offsetCalc(l3, height*l3curvature) apexPoint10(i,j) = offsetCalc(h4, height*h4curvature) apexPoint11(i,j) = offsetCalc(k4, height*k4curvature) apexPoint12(i,j) = offsetCalc(l4, height*l4curvature) Dim ag3, af3, kf3, bf3, bh3, be3, le3, ce3, cd3 Dim fg3, fh3, eh3, de3, cl3, bl3, bk3, ak3 Dim ag4, af4, kf4, bf4, bh4, be4, le4, ce4, cd4 Dim fg4, fh4, eh4, de4, cl4, bl4, bk4, ak4 ag3 = Rhino.AddLine(a3, g3) af3 = Rhino.AddLine(a3, f3) kf3 = Rhino.AddLine(apexPoint8(i,j), f3) bf3 = Rhino.AddLine(b3, f3) bh3 = Rhino.AddLine(b3, apexPoint7(i,j)) be3 = Rhino.AddLine(b3, e3) le3 = Rhino.AddLine(apexPoint9(i,j), e3) ce3 = Rhino.AddLine(c3, e3) cd3 = Rhino.AddLine(c3, d3) fg3 = Rhino.AddLine(f3, g3) fh3 = Rhino.AddLine(f3, apexPoint7(i,j)) eh3 = Rhino.AddLine(e3, apexPoint7(i,j)) de3 = Rhino.AddLine(d3, e3) cl3 = Rhino.AddLine(c3, apexPoint9(i,j)) bl3 = Rhino.AddLine(b3, apexPoint9(i,j)) bk3 = Rhino.AddLine(b3, apexPoint8(i,j)) ak3 = Rhino.AddLine(a3, apexPoint8(i,j)) ag4 = Rhino.AddLine(a4, g4) af4 = Rhino.AddLine(a4, f4) kf4 = Rhino.AddLine(apexPoint11(i,j), f4) bf4 = Rhino.AddLine(b4, f4) bh4 = Rhino.AddLine(b4, apexPoint10(i,j)) be4 = Rhino.AddLine(b4, e4) le4 = Rhino.AddLine(apexPoint12(i,j), e4) ce4 = Rhino.AddLine(c4, e4) cd4 = Rhino.AddLine(c4, d4) fg4 = Rhino.AddLine(f4, g4) fh4 = Rhino.AddLine(f4, apexPoint10(i,j)) eh4 = Rhino.AddLine(e4, apexPoint10(i,j)) de4 = Rhino.AddLine(d4, e4) cl4 = Rhino.AddLine(c4, apexPoint12(i,j)) bl4 = Rhino.AddLine(b4, apexPoint12(i,j)) bk4 = Rhino.AddLine(b4, apexPoint11(i,j)) ak4 = Rhino.AddLine(a4, apexPoint11(i,j)) Dim arrObjects3, arrObjects4 Dim arrafg3, arrafk3, arrbfk3, arrbfh3, arrbeh3, arrbel3, arrcel3, arrcde3 Dim arrafg4, arrafk4, arrbfk4, arrbfh4, arrbeh4, arrbel4, arrcel4, arrcde4 Dim afg3, afk3, bfk3, bfh3, beh3, bel3, cel3, cde3 Dim afg4, afk4, bfk4, bfh4, beh4, bel4, cel4, cde4 arrafg3 = Array(af3, ag3, fg3) arrafk3 = Array(af3, kf3, ak3) arrbfk3 = Array(bf3, bk3, kf3) arrbfh3 = Array(bf3, bh3, fh3) arrbeh3 = Array(be3, eh3, bh3) arrbel3 = Array(be3, le3, bl3) arrcel3 = Array(ce3, le3, cl3) arrcde3 = Array(cd3, de3, ce3) arrafg4 = Array(af4, ag4, fg4) arrafk4 = Array(af4, kf4, ak4) arrbfk4 = Array(bf4, bk4, kf4) arrbfh4 = Array(bf4, bh4, fh4) arrbeh4 = Array(be4, eh4, bh4) arrbel4 = Array(be4, le4, bl4) arrcel4 = Array(ce4, le4, cl4) arrcde4 = Array(cd4, de4, ce4) afg3 = Rhino.AddPlanarSrf(arrafg3) afk3 = Rhino.AddPlanarSrf(arrafk3) bfk3 = Rhino.AddPlanarSrf(arrbfk3) bfh3 = Rhino.AddPlanarSrf(arrbfh3) beh3 = Rhino.AddPlanarSrf(arrbeh3) bel3 = Rhino.AddPlanarSrf(arrbel3) cel3 = Rhino.AddPlanarSrf(arrcel3) cde3 = Rhino.AddPlanarSrf(arrcde3) afg4 = Rhino.AddPlanarSrf(arrafg4) afk4 = Rhino.AddPlanarSrf(arrafk4) bfk4 = Rhino.AddPlanarSrf(arrbfk4) bfh4 = Rhino.AddPlanarSrf(arrbfh4) beh4 = Rhino.AddPlanarSrf(arrbeh4) bel4 = Rhino.AddPlanarSrf(arrbel4) cel4 = Rhino.AddPlanarSrf(arrcel4) cde4 = Rhino.AddPlanarSrf(arrcde4) Dim strSurface3, strSurface4 arrObjects3 = Array(abk1, bko1, bho1, bhm1, dmh1, dhq1, dfq1, def1) 'strSurface3 = Rhino.JoinSurfaces(arrObjects3, True) arrObjects4 = Array(abk2, bko2, bho2, bhm2, dmh2, dhq2, dfq2, def2) 'strSurface4 = Rhino.JoinSurfaces(arrObjects4, True) Next Next

End Sub

'Call the sub skin01

''' 'This fucntion finds the coordinate of a point normal to, and at a from, a point on the surface Function offsetCalc(oData, height) Dim vscaled vscaled = VectorScale(oData(1),height) offsetCalc = VectorAdd(vscaled,oData(0)) End Function

'' 'function by RMA, "vectors.rvb" Function VectorAdd(v1, v2)

VectorAdd = Null If Not IsArray(v1) Or (UBound(v1) <> 2) Then Exit Function If Not IsArray(v2) Or (UBound(v2) <> 2) Then Exit Function VectorAdd = Array(v1(0) + v2(0), v1(1) + v2(1), v1(2) + v2(2))

End Function

'' 'function by RMA, "vectors.rvb" Function VectorScale(v, d)

VectorScale = Null If Not IsArray(v) Or (UBound(v) <> 2) Then Exit Function If Not IsNumeric(d) Then Exit Function VectorScale = Array(v(0) * d, v(1) * d, v(2) * d)

End Function

' 'This function checks if the current layer is and if it isn't, makes it so. If the layer doesn't '    exist then it creates it with the name. Function CheckLayer(layername) If Rhino.IsLayer(layername) Then Rhino.CurrentLayer(layername) Else Rhino.AddLayer(layername) Rhino.CurrentLayer(layername) End If End Function