Option explicit 'component surface array 'Chicho Goldberg 'batman 'modified from 'skin panel prototype 'joshua vermillion Dim sourceSurface,sourceSurface2, uDiv, vDiv, height Dim uStep, vStep Dim uVal, vVal Dim ap1 ,ap2, ap1Vnext,ap1Unext,ap2Vnext,ap2Unext Dim a0, a4, e0, e4, c4, b1,d1,b3,d3, b1neg,d1neg,b3neg,d3neg Dim a0_2, a4_2, e0_2, e4_2, ap1_2, ap2_2 Dim a0ap1,a0ap1neg,a4ap1,a4ap1neg,e0ap1,e0ap1neg,e4ap1,e4ap1neg Dim initialU, inialV, initialheight Dim a4pos, a4neg, e4pos,e4neg,a0pos,a0neg,e0pos, e0neg Dim parentLayer Dim c1,c1neg,c2,c2neg Dim s1 Dim red : red = RGB(245,0,0) Dim green : green = RGB(0,255,0) Dim blue : blue = RGB(0,0,255) Dim yellow : yellow = RGB(255,255,0) Dim purple : purple = RGB(255,0,255) Dim black : black = RGB(0,0,0) Dim white : white = RGB(255,255,255) Dim pink : pink = RGB(226,33,141) Dim Attract_01 Dim aVal, dist Dim maxheight initialU = 15 inialV = 26 initialheight = .15 maxheight = .4 Sub panel Dim i, j ,k Dim sourceCurves sourceSurface = Rhino.GetObject("Select first surface to populate", 8,, True) Rhino.Command "Reparameterize 0 1 0 1 " sourceSurface2 = Rhino.GetObject("Select second surface to populate", 8,, True) 'sourceCurves = Rhino.GetObjects("Select curves", 4,, True) parentLayer = Rhino.GetString("Enter layer name", 1) uDiv = Rhino.GetInteger("Enter the number of divisions in the U direction", initialU, 1) vDiv = Rhino.GetInteger("Enter the number of divisions in the V direction", inialV, 1) height = Rhino.GetReal("Enter a height/width", initialheight) 'Rhino.Command "SelNone" 'Rhino.LastCreatedObjects True Rhino.Command "Reparameterize 0 1 0 1 " ' Attract_01 = Rhino.Getpoint("attractor point 01") Rhino.EnableRedraw(vbFalse) 'set's arrays to contain various point data ReDim ap1 ((uDiv-1),(vDiv-1)) ReDim ap2 ((uDiv-1),(vDiv-1)) ReDim a0 ((uDiv-1),(vDiv-1)) ReDim a4 ((uDiv-1),(vDiv-1)) ReDim e0 ((uDiv-1),(vDiv-1)) ReDim e4 ((uDiv-1),(vDiv-1)) ReDim c4 ((uDiv-1),(vDiv-1)) ReDim ap1_2 ((uDiv-1),(vDiv-1)) ReDim ap2_2 ((uDiv-1),(vDiv-1)) ReDim a0_2 ((uDiv-1),(vDiv-1)) ReDim a4_2 ((uDiv-1),(vDiv-1)) ReDim e0_2 ((uDiv-1),(vDiv-1)) ReDim e4_2 ((uDiv-1),(vDiv-1)) ReDim c4_2 ((uDiv-1),(vDiv-1)) ReDim b1 ((uDiv-1),(vDiv-1)) ReDim d1 ((uDiv-1),(vDiv-1)) ReDim b3 ((uDiv-1),(vDiv-1)) ReDim d3 ((uDiv-1),(vDiv-1)) ReDim b1neg ((uDiv-1),(vDiv-1)) ReDim d1neg ((uDiv-1),(vDiv-1)) ReDim b3neg ((uDiv-1),(vDiv-1)) ReDim d3neg ((uDiv-1),(vDiv-1)) ReDim e0pos ((uDiv-1),(vDiv-1)) ReDim e0neg ((uDiv-1),(vDiv-1)) ReDim a0pos ((uDiv-1),(vDiv-1)) ReDim a0neg ((uDiv-1),(vDiv-1)) ReDim a4pos ((uDiv-1),(vDiv-1)) ReDim a4neg ((uDiv-1),(vDiv-1)) ReDim e4pos ((uDiv-1),(vDiv-1)) ReDim e4neg ((uDiv-1),(vDiv-1)) ReDim a0ap1 ((uDiv-1),(vDiv-1)) ReDim a0ap1neg ((uDiv-1),(vDiv-1)) ReDim a4ap1 ((uDiv-1),(vDiv-1)) ReDim a4ap1neg ((uDiv-1),(vDiv-1)) ReDim e0ap1 ((uDiv-1),(vDiv-1)) ReDim e0ap1neg ((uDiv-1),(vDiv-1)) ReDim e4ap1 ((uDiv-1),(vDiv-1)) ReDim e4ap1neg ((uDiv-1),(vDiv-1)) ReDim c1 ((uDiv-1),(vDiv-1)) ReDim c1neg ((uDiv-1),(vDiv-1)) ReDim c2 ((uDiv-1),(vDiv-1)) ReDim c2neg ((uDiv-1),(vDiv-1)) ReDim s1((uDiv-1),(vDiv-1)) ReDim dist ((uDiv-1),(vDiv-1)) ReDim aVal ((uDiv-1),(vDiv-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) '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 Next For i = 0 To vDiv vVal(i) = i * vStep Next 'Start looping through each u and v division and create point array information For i = 0 To uDiv-1 For j = 0 To vDiv-1 construct_Attractors i,j Next Next maxDist(dist) For i = 0 To uDiv-1 For j = 0 To vDiv-1 k = limit ((50*aVal(i,j)),0,1) construct i,j,k Next Next For i = 0 To uDiv-1 For j = 0 To vDiv-1 k = limit ((50*aVal(i,j)),0,1) construct_2 i,j,k Next Next For i = 0 To uDiv-1 For j = 0 To vDiv-1 lattice i,j Next Next ' main component constructuin For i = 3 To uDiv-4 For j = 2 To vDiv-2 component1 i,j,0 j=j+1 Next i=i+3 Next For i = 1 To uDiv-3 For j = 1 To vDiv-2 component1 i,j,0 j=j+1 Next i=i+3 Next For i = 3 To uDiv-4 j=0 componentTop i,j,0 i=i+3 Next For i = 1 To uDiv-3 j=vDiv-1 componentBottom i,j,0 i=i+3 Next For j = 2 To vDiv-2 i=-1 componentRight i,j,0 j=j+1 Next For j = 1 To vDiv-2 i=uDiv-2 componentLeft i,j,0 j=j+1 Next ' componentTop 4,4,0 ' componentLeft 8,8,0 ' componentright 6,6,0 ' componentBottom 2,2,0 ' component1 2,6,0 ' component1 6,6,0 ' component1 2,4,0 ' component1 6,4,0 ' component1 2,2,0 ' component1 6,2,0 ' ' ' component1 4,1,0 ' component1 4,3,0 ' component1 4,5,0 ' component1 4,7,0 ' component1 4,18,8 ' component1 4,16,7 ' component1 4,14,6 ' component1 4,12,5 ' component1 4,10,4 ' component1 4,8,3 ' component1 4,6,2 ' component1 4,4,1 ' component1 4,2,0 ' component1 4,4,1 Dim YN:YN= Rhino.MessageBox ("Delete construction curves?" , 4) If YN =6 Then Rhino.PurgeLayer ("construction") 'Rhino.DeleteObjects (sourceSurface) End If 'surface() ''sound to end script Dim objShell, strCommand 'change the path to any .wav file of your choice ' Dim strSoundFile : strSoundFile = "C:\WINDOWS\Media\Notify.wav" ' ' Set objShell = CreateObject("Wscript.Shell") ' strCommand = "sndrec32 /play /close " & chr(34) & strSoundFile & chr(34) ' objShell.Run strCommand, 0, True Rhino.EnableRedraw(vbTrue) End Sub panel Function construct_Attractors (i,j) checkLayerParent (parentLayer) Dim cent_1 : cent_1 = Rhino.EvaluateSurface(sourceSurface,Array(uVal(i)+(uVal(1)*(.5)) , vVal(j)+vVal(1)*(.5))) ' dist (i,j) = rhino.Distance(cent_1, Attract_01) ' print dist (i,j) Dim curvature : curvature = rhino.SurfaceCurvature(sourceSurface, Array(uVal(i)+(uVal(1)*(.5)) , vVal(j)+vVal(1)*(.5))) dist (i,j) = abs (curvature (7)) End Function Function construct_2 (i,j,k) Dim ac : ac = k checkLayerParent (parentLayer) Dim componentColor : componentColor = RGB(125,125,125) 'top left corner Dim a4a : a4a = Rhino.EvaluateSurface(sourceSurface2, Array(uVal(i), vVal(j))) 'top right corner Dim e4a : e4a = Rhino.EvaluateSurface(sourceSurface2, Array(uVal(i)+uVal(1), vVal(j))) 'bottome left corner Dim a0a : a0a = Rhino.EvaluateSurface(sourceSurface2, Array(uVal(i), vVal(j)+ vVal(1))) 'bottom right corner Dim e0a : e0a = Rhino.EvaluateSurface(sourceSurface2, Array(uVal(i)+uVal(1), vVal(j)+vVal(1))) 'find normal to center point Dim b2 : b2 = Rhino.SurfaceCurvature(sourceSurface2, Array(uVal(i)+(uVal(1)*(.5)) , vVal(j)+vVal(1)*(.5))) Dim calHe : calHe = limit((height+1*(1/(aVal(i,j)+.01))),.001,maxheight) '+sin(i) ' ((.2*sin (i) + .2*sin (j)) / 2) + Dim calHe2 : calHe2 = limit((height+1*(1/(aVal(i,j)+.01))),.001,maxheight) '+sin(j) ' ((.2*sin (i) + .2*sin (j)) / 2) +.1 ap1_2(i,j) = offsetCalc(b2, calHe) ap2_2(i,j) = offsetCalc(b2, -(calHe)) Dim ap1ap2 : ap1ap2 = rhino.AddLine (ap1(i,j), ap2(i,j)) Dim cent_a : cent_a = AddPointAtR1Parameter(ap1ap2, .9) Dim a4ctrl : a4ctrl = rhino.AddLine (a4a, cent_a) Dim e4ctrl : e4ctrl = rhino.AddLine (e4a, cent_a) Dim a0ctrl : a0ctrl = rhino.AddLine (a0a, cent_a) Dim e0ctrl : e0ctrl = rhino.AddLine (e0a, cent_a) a4_2(i,j) = AddPointAtR1Parameter(a4ctrl, ac) e4_2(i,j) = AddPointAtR1Parameter(e4ctrl, ac) a0_2(i,j) = AddPointAtR1Parameter(a0ctrl, ac) e0_2(i,j) = AddPointAtR1Parameter(e0ctrl, ac) End Function Function construct (i,j,k) Dim ac : ac = k checkLayerParent (parentLayer) Dim componentColor : componentColor = RGB(125,125,125) 'top left corner Dim a4a : a4a = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i), vVal(j))) 'top right corner Dim e4a : e4a = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+uVal(1), vVal(j))) 'bottome left corner Dim a0a : a0a = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i), vVal(j)+ vVal(1))) 'bottom right corner Dim e0a : e0a = Rhino.EvaluateSurface(sourceSurface, Array(uVal(i)+uVal(1), vVal(j)+vVal(1))) 'find normal to center point Dim b2 : b2 = Rhino.SurfaceCurvature(sourceSurface, Array(uVal(i)+(uVal(1)*(.5)) , vVal(j)+vVal(1)*(.5))) Dim calHe : calHe = limit((height+1*(1/(aVal(i,j)+.01))),.001,maxheight) ' ((.2*sin (i) + .2*sin (j)) / 2) + Dim calHe2 : calHe2 = limit((height+1*(1/(aVal(i,j)+.01))),.001,maxheight) ' ((.2*sin (i) + .2*sin (j)) / 2) +.1 ap1(i,j) = offsetCalc(b2, calHe) ap2(i,j) = offsetCalc(b2, -(calHe)) Dim ap1ap2 : ap1ap2 = rhino.AddLine (ap1(i,j), ap2(i,j)) Dim cent_a : cent_a = AddPointAtR1Parameter(ap1ap2, .1) Dim a4ctrl : a4ctrl = rhino.AddLine (a4a, cent_a) Dim e4ctrl : e4ctrl = rhino.AddLine (e4a, cent_a) Dim a0ctrl : a0ctrl = rhino.AddLine (a0a, cent_a) Dim e0ctrl : e0ctrl = rhino.AddLine (e0a, cent_a) a4(i,j) = AddPointAtR1Parameter(a4ctrl, ac) e4(i,j) = AddPointAtR1Parameter(e4ctrl, ac) a0(i,j) = AddPointAtR1Parameter(a0ctrl, ac) e0(i,j) = AddPointAtR1Parameter(e0ctrl, ac) End Function Function lattice (i,j) Dim tVal : tVal = .5 ''contrust initial octahedron CheckLayer "a0b1" , red a0ap1(i,j) = rhino.AddLine (a0(i,j), ap1(i,j)) a0ap1neg(i,j) = rhino.AddLine (a0_2(i,j), ap2_2(i,j)) ' Dim a0nega0pos : a0nega0pos = rhino.AddLine (a0neg(i,j), a0pos(i,j)) CheckLayer "a4b3" , yellow a4ap1(i,j) = rhino.AddLine (a4(i,j), ap1(i,j)) a4ap1neg(i,j) = rhino.AddLine (a4_2(i,j), ap2_2(i,j)) ' Dim a4nega4pos : a4nega4pos = rhino.AddLine (a4neg(i,j), a4pos(i,j)) CheckLayer "e0d1" , green e0ap1(i,j) = rhino.AddLine (e0(i,j), ap1(i,j)) e0ap1neg(i,j) = rhino.AddLine (e0_2(i,j), ap2_2(i,j)) ' Dim e0nege0pos : e0nege0pos = rhino.AddLine (e0neg(i,j), e0pos(i,j)) CheckLayer "e4d3" , purple e4ap1(i,j) = rhino.AddLine (e4(i,j),ap1(i,j)) e4ap1neg(i,j) = rhino.AddLine (e4_2(i,j),ap2_2(i,j)) ' Dim e4nege4pos : e4nege4pos = rhino.AddLine (e4neg(i,j), e4pos(i,j)) CheckLayer "aP" , black Dim ap1ap2 : ap1ap2 = rhino.AddLine (ap1(i,j),ap2(i,j)) End Function Function component1 (i,j, stretchlevel) Dim k, k2 k = 3+stretchlevel k2 = stretchlevel+1 'If i < uDiv-2 And j >= 1 And i >=1 And j < uDiv-2 Then CheckLayer "connection1" , white Dim c1 : c1 = rhino.AddLine (ap1(i,j),ap1(i+1,j+1)) Dim c1neg : c1neg = rhino.AddLine (ap2_2(i,j),ap2_2(i+1,j+1)) CheckLayer "connection3" , white Dim c3 : c3 = rhino.AddLine (ap1(i,j),ap1(i+1,j-1)) Dim c3neg : c3neg = rhino.AddLine (ap2_2(i,j),ap2_2(i+1,j-1)) CheckLayer "connection2" , red Dim c2 : c2 = rhino.AddLine (ap1(i+1,j),ap1(i,j)) Dim c2neg : c2neg = rhino.AddLine (ap2_2(i+1,j),ap2_2(i,j)) CheckLayer "connection1Mir" , black Dim c1mir : c1mir = rhino.AddLine (ap1(i+2,j),ap1(i+1,j+1)) Dim c1mirneg : c1mirneg = rhino.AddLine (ap2_2(i+2,j),ap2_2(i+1,j+1)) CheckLayer "connection3Mir" , black Dim c3mir : c3mir = rhino.AddLine (ap1(i+2,j),ap1(i+1,j-1)) Dim c3mirneg : c3mirneg = rhino.AddLine (ap2_2(i+2,j),ap2_2(i+1,j-1)) CheckLayer "connection2mir" , red Dim c2mir : c2mir = rhino.AddLine (ap1(i+1,j),ap1(i+2,j)) Dim c2mirneg : c2mirneg = rhino.AddLine (ap2_2(i+1,j),ap2_2(i+2,j)) CheckLayer "surface" , red rhino.addloftsrf array( c2,a0ap1(i+1,j-1)) rhino.addloftsrf array( c2,a4ap1(i+1,j+1)) rhino.addloftsrf array( c3,e4ap1(i-k2,j)) rhino.addloftsrf array( c1,e0ap1(i-k2,j)) rhino.ReverseCurve e0ap1neg(i-k2,j) rhino.addloftsrf array( e0ap1neg(i-k2,j),a0ap1(i-k2,j)) rhino.ReverseCurve e0ap1neg(i-k2,j) rhino.addloftsrf array( c2mir,e0ap1(i+1,j-1)) rhino.addloftsrf array( c2mir,e4ap1(i+1,j+1)) rhino.addloftsrf array( c1mir,a0ap1(i+k,j)) rhino.addloftsrf array( c3mir,a4ap1(i+k,j)) rhino.ReverseCurve a4ap1(i+k,j) rhino.addloftsrf array( e4ap1neg(i+k,j),a4ap1(i+k,j)) rhino.ReverseCurve a4ap1(i+k,j) CheckLayer "surfaceMir" , red rhino.addloftsrf array( c2neg,a0ap1neg(i+1,j-1)) rhino.addloftsrf array( c2neg,a4ap1neg(i+1,j+1)) rhino.addloftsrf array( c3neg,e4ap1neg(i-k2,j)) rhino.addloftsrf array( c1neg,e0ap1neg(i-k2,j)) rhino.addloftsrf array( c2mirneg,e0ap1neg(i+1,j-1)) rhino.addloftsrf array( c2mirneg,e4ap1neg(i+1,j+1)) rhino.addloftsrf array( c1mirneg,a0ap1neg(i+k,j)) rhino.addloftsrf array( c3mirneg,a4ap1neg(i+k,j)) 'End If End Function Function componentLeft (i,j, stretchlevel) ''left side Dim k, k2 k = 3+stretchlevel k2 = stretchlevel+1 'If i < uDiv-2 And j >= 1 And i >=1 And j < uDiv-2 Then CheckLayer "connection1" , white Dim c1 : c1 = rhino.AddLine (ap1(i,j),ap1(i+1,j+1)) Dim c1neg : c1neg = rhino.AddLine (ap2_2(i,j),ap2_2(i+1,j+1)) CheckLayer "connection3" , white Dim c3 : c3 = rhino.AddLine (ap1(i,j),ap1(i+1,j-1)) Dim c3neg : c3neg = rhino.AddLine (ap2_2(i,j),ap2_2(i+1,j-1)) CheckLayer "connection2" , red Dim c2 : c2 = rhino.AddLine (ap1(i+1,j),ap1(i,j)) Dim c2neg : c2neg = rhino.AddLine (ap2_2(i+1,j),ap2_2(i,j)) ' CheckLayer "connection2mir" , red ' Dim c2mir : c2mir = rhino.AddLine (ap1(i+1,j),ap1(i+2,j)) ' Dim c2mirneg : c2mirneg = rhino.AddLine (ap2_2(i+1,j),ap2_2(i+2,j)) CheckLayer "surfaceleft" , blue rhino.addloftsrf array( c2,a0ap1(i+1,j-1)) rhino.addloftsrf array( c2,a4ap1(i+1,j+1)) rhino.addloftsrf array( c3,e4ap1(i-k2,j)) rhino.addloftsrf array( c1,e0ap1(i-k2,j)) rhino.ReverseCurve e0ap1neg(i-k2,j) rhino.addloftsrf array( e0ap1neg(i-k2,j),a0ap1(i-k2,j)) rhino.ReverseCurve e0ap1neg(i-k2,j) ''rhino.addloftsrf array( c2mir,e0ap1(i+1,j-1)) '' rhino.addloftsrf array( c2mir,e4ap1(i+1,j+1)) 'rhino.addloftsrf array( c1mir,a0ap1(i+k,j)) 'rhino.addloftsrf array( c3mir,a4ap1(i+k,j)) ' rhino.ReverseCurve a4ap1(i+k,j) ' rhino.addloftsrf array( e4ap1neg(i+k,j),a4ap1(i+k,j)) ' rhino.ReverseCurve a4ap1(i+k,j) CheckLayer "surfaceMirleft" , blue rhino.addloftsrf array( c2neg,a0ap1neg(i+1,j-1)) rhino.addloftsrf array( c2neg,a4ap1neg(i+1,j+1)) rhino.addloftsrf array( c3neg,e4ap1neg(i-k2,j)) rhino.addloftsrf array( c1neg,e0ap1neg(i-k2,j)) '' rhino.addloftsrf array( c2mirneg,e0ap1neg(i+1,j-1)) '' rhino.addloftsrf array( c2mirneg,e4ap1neg(i+1,j+1)) ' rhino.addloftsrf array( c1mirneg,a0ap1neg(i+k,j)) ' rhino.addloftsrf array( c3mirneg,a4ap1neg(i+k,j)) 'End If End Function Function componentRight (i,j, stretchlevel)'right side Dim k, k2 k = 3+stretchlevel k2 = stretchlevel+1 'If i < uDiv-2 And j >= 1 And i >=1 And j < uDiv-2 Then CheckLayer "connection2" , red CheckLayer "connection1Mir" , black Dim c1mir : c1mir = rhino.AddLine (ap1(i+2,j),ap1(i+1,j+1)) Dim c1mirneg : c1mirneg = rhino.AddLine (ap2_2(i+2,j),ap2_2(i+1,j+1)) CheckLayer "connection3Mir" , black Dim c3mir : c3mir = rhino.AddLine (ap1(i+2,j),ap1(i+1,j-1)) Dim c3mirneg : c3mirneg = rhino.AddLine (ap2_2(i+2,j),ap2_2(i+1,j-1)) CheckLayer "connection2mir" , red Dim c2mir : c2mir = rhino.AddLine (ap1(i+1,j),ap1(i+2,j)) Dim c2mirneg : c2mirneg = rhino.AddLine (ap2_2(i+1,j),ap2_2(i+2,j)) CheckLayer "surfaceright" , blue ' rhino.addloftsrf array( c2,a0ap1(i+1,j-1)) 'rhino.addloftsrf array( c2,a4ap1(i+1,j+1)) ' rhino.ReverseCurve e0ap1neg(i-k2,j) ' rhino.addloftsrf array( e0ap1neg(i-k2,j),a0ap1(i-k2,j)) ' rhino.ReverseCurve e0ap1neg(i-k2,j) rhino.addloftsrf array( c2mir,e0ap1(i+1,j-1)) rhino.addloftsrf array( c2mir,e4ap1(i+1,j+1)) rhino.addloftsrf array( c1mir,a0ap1(i+k,j)) rhino.addloftsrf array( c3mir,a4ap1(i+k,j)) rhino.ReverseCurve a4ap1(i+k,j) rhino.addloftsrf array( e4ap1neg(i+k,j),a4ap1(i+k,j)) rhino.ReverseCurve a4ap1(i+k,j) CheckLayer "surfaceMirright" , blue 'rhino.addloftsrf array( c2neg,a0ap1neg(i+1,j-1)) ' rhino.addloftsrf array( c2neg,a4ap1neg(i+1,j+1)) rhino.addloftsrf array( c2mirneg,e0ap1neg(i+1,j-1)) rhino.addloftsrf array( c2mirneg,e4ap1neg(i+1,j+1)) rhino.addloftsrf array( c1mirneg,a0ap1neg(i+k,j)) rhino.addloftsrf array( c3mirneg,a4ap1neg(i+k,j)) 'End If End Function Function componentBottom (i,j, stretchlevel) Dim k, k2 k = 3+stretchlevel k2 = stretchlevel+1 'If i < uDiv-2 And j >= 1 And i >=1 And j < uDiv-2 Then CheckLayer "connection1" , white CheckLayer "connection3" , white Dim c3 : c3 = rhino.AddLine (ap1(i,j),ap1(i+1,j-1)) Dim c3neg : c3neg = rhino.AddLine (ap2_2(i,j),ap2_2(i+1,j-1)) CheckLayer "connection2" , red Dim c2 : c2 = rhino.AddLine (ap1(i+1,j),ap1(i,j)) Dim c2neg : c2neg = rhino.AddLine (ap2_2(i+1,j),ap2_2(i,j)) CheckLayer "connection1Mir" , black CheckLayer "connection3Mir" , black Dim c3mir : c3mir = rhino.AddLine (ap1(i+2,j),ap1(i+1,j-1)) Dim c3mirneg : c3mirneg = rhino.AddLine (ap2_2(i+2,j),ap2_2(i+1,j-1)) CheckLayer "connection2mir" , red Dim c2mir : c2mir = rhino.AddLine (ap1(i+1,j),ap1(i+2,j)) Dim c2mirneg : c2mirneg = rhino.AddLine (ap2_2(i+1,j),ap2_2(i+2,j)) CheckLayer "surfacebottom" , blue rhino.addloftsrf array( c2,a0ap1(i+1,j-1)) ' rhino.addloftsrf array( c2,a4ap1(i+1,j+1)) rhino.addloftsrf array( c3,e4ap1(i-k2,j)) ' rhino.addloftsrf array( c1,e0ap1(i-k2,j)) rhino.ReverseCurve e0ap1neg(i-k2,j) ' rhino.addloftsrf array( e0ap1neg(i-k2,j),a0ap1(i-k2,j)) rhino.ReverseCurve e0ap1neg(i-k2,j) rhino.addloftsrf array( c2mir,e0ap1(i+1,j-1)) ' rhino.addloftsrf array( c2mir,e4ap1(i+1,j+1)) ' rhino.addloftsrf array( c1mir,a0ap1(i+k,j)) rhino.addloftsrf array( c3mir,a4ap1(i+k,j)) rhino.ReverseCurve a4ap1(i+k,j) rhino.addloftsrf array( e4ap1neg(i+k,j),a4ap1(i+k,j)) rhino.ReverseCurve a4ap1(i+k,j) CheckLayer "surfaceMirBottom" , blue rhino.addloftsrf array( c2neg,a0ap1neg(i+1,j-1)) ' rhino.addloftsrf array( c2neg,a4ap1neg(i+1,j+1)) rhino.addloftsrf array( c3neg,e4ap1neg(i-k2,j)) ' rhino.addloftsrf array( c1neg,e0ap1neg(i-k2,j)) rhino.addloftsrf array( c2mirneg,e0ap1neg(i+1,j-1)) 'rhino.addloftsrf array( c2mirneg,e4ap1neg(i+1,j+1)) ' rhino.addloftsrf array( c1mirneg,a0ap1neg(i+k,j)) rhino.addloftsrf array( c3mirneg,a4ap1neg(i+k,j)) 'End If End Function Function componentTop (i,j, stretchlevel) Dim k, k2 k = 3+stretchlevel k2 = stretchlevel+1 'If i < uDiv-2 And j >= 1 And i >=1 And j < uDiv-2 Then CheckLayer "connection1" , white Dim c1 : c1 = rhino.AddLine (ap1(i,j),ap1(i+1,j+1)) Dim c1neg : c1neg = rhino.AddLine (ap2_2(i,j),ap2_2(i+1,j+1)) CheckLayer "connection3" , white CheckLayer "connection2" , red Dim c2 : c2 = rhino.AddLine (ap1(i+1,j),ap1(i,j)) Dim c2neg : c2neg = rhino.AddLine (ap2_2(i+1,j),ap2_2(i,j)) CheckLayer "connection1Mir" , black Dim c1mir : c1mir = rhino.AddLine (ap1(i+2,j),ap1(i+1,j+1)) Dim c1mirneg : c1mirneg = rhino.AddLine (ap2_2(i+2,j),ap2_2(i+1,j+1)) CheckLayer "connection3Mir" , black CheckLayer "connection2mir" , red Dim c2mir : c2mir = rhino.AddLine (ap1(i+1,j),ap1(i+2,j)) Dim c2mirneg : c2mirneg = rhino.AddLine (ap2_2(i+1,j),ap2_2(i+2,j)) CheckLayer "surfaceTop" , blue ' rhino.addloftsrf array( c2,a0ap1(i+1,j-1)) rhino.addloftsrf array( c2,a4ap1(i+1,j+1)) ' rhino.addloftsrf array( c3,e4ap1(i-k2,j)) rhino.addloftsrf array( c1,e0ap1(i-k2,j)) rhino.ReverseCurve e0ap1neg(i-k2,j) rhino.addloftsrf array( e0ap1neg(i-k2,j),a0ap1(i-k2,j)) rhino.ReverseCurve e0ap1neg(i-k2,j) 'rhino.addloftsrf array( c2mir,e0ap1(i+1,j-1)) rhino.addloftsrf array( c2mir,e4ap1(i+1,j+1)) rhino.addloftsrf array( c1mir,a0ap1(i+k,j)) 'rhino.addloftsrf array( c3mir,a4ap1(i+k,j)) rhino.ReverseCurve a4ap1(i+k,j) 'rhino.addloftsrf array( e4ap1neg(i+k,j),a4ap1(i+k,j)) rhino.ReverseCurve a4ap1(i+k,j) CheckLayer "surfaceMirTop" , blue 'rhino.addloftsrf array( c2neg,a0ap1neg(i+1,j-1)) rhino.addloftsrf array( c2neg,a4ap1neg(i+1,j+1)) 'rhino.addloftsrf array( c3neg,e4ap1neg(i-k2,j)) rhino.addloftsrf array( c1neg,e0ap1neg(i-k2,j)) 'rhino.addloftsrf array( c2mirneg,e0ap1neg(i+1,j-1)) rhino.addloftsrf array( c2mirneg,e4ap1neg(i+1,j+1)) rhino.addloftsrf array( c1mirneg,a0ap1neg(i+k,j)) 'rhino.addloftsrf array( c3mirneg,a4ap1neg(i+k,j)) 'End If End Function Function maxDist (d) Dim i,j maxDist = 0 For i = 0 To uDiv-1 For j = 0 To vDiv-1 If d(i,j) > maxDist Then maxDist = d(i,j) End If Next Next For i = 0 To uDiv-1 For j = 0 To vDiv-1 aVal (i,j) = d(i,j) / maxDist print aVal(i,j) Next Next print maxDist End Function Function AddPointAtR1Parameter(strCurveID, dblUnitParameter) AddPointAtR1Parameter = Null Dim crvDomain : crvDomain = Rhino.CurveDomain(strCurveID) If IsNull(crvDomain) Then Exit Function Dim dblR1Param dblR1Param = crvDomain(0) + dblUnitParameter * (crvDomain(1) - crvDomain(0)) Dim arrR3Point : arrR3Point = Rhino.EvaluateCurve(strCurveID, dblR1Param) If Not IsArray(arrR3Point) Then Exit Function Dim strPointID : strPointID = Rhino.AddPoint(arrR3Point) Call Rhino.ObjectColor(strPointID, ParameterColour(dblUnitParameter)) AddPointAtR1Parameter = arrR3Point End Function Function Limit(input, min, max) Limit = input If input > max Then Limit = max End If If input < min Then Limit = min End If End Function Function ParameterColour(dblParam) Dim RedComponent : RedComponent = 255 * dblParam If (RedComponent < 0) Then RedComponent = 0 If (RedComponent > 255) Then RedComponent = 255 ParameterColour = RGB(RedComponent, 0, 255 - RedComponent) End Function Function edgeSurface(edge1,edge2) Dim f : f = Rhino.CurveDirectionsMatch(edge1,edge2) Dim rEdge Dim arr If f = False Then rEdge= Rhino.ReverseCurve(edge1) arr = Array(edge1, rEdge ) End If If f = True Then arr = Array(edge1, edge2 ) End If Rhino.AddEdgeSrf (arr) End Function Function loftSurface(edge1,edge2) Dim f : f = Rhino.CurveDirectionsMatch(edge1,edge2) Dim rEdge Dim arr If f = True Then rEdge= Rhino.ReverseCurve(edge2) arr = Array(edge1, rEdge ) End If If f = False Then arr = Array(edge1, edge2 ) End If rhino.AddLoftSrf arr End Function Function loftSurface2(edge1,edge2) Dim f : f = Rhino.CurveDirectionsMatch(edge1,edge2) Dim rEdge Dim arr If f = False Then rEdge= Rhino.ReverseCurve(edge2) arr = Array(edge1, rEdge ) End If If f = true Then arr = Array(edge1, edge2 ) End If rhino.AddLoftSrf arr End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '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) Dim forwardback Dim leftright forwardback = 0 leftright = 0 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)+forwardback, v1(1) + v2(1)+leftright, 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 CheckLayerParent(layername) If Rhino.IsLayer(layername) Then Rhino.CurrentLayer(layername) Else Rhino.AddLayer layername Rhino.CurrentLayer(layername) End If End Function Function CheckLayer(layername,color) If Rhino.IsLayerChildOf(parentLayer, layername+"_"+parentLayer) Then Rhino.CurrentLayer(layername+"_"+parentLayer) Else Rhino.AddLayer layername+"_"+parentLayer,color,,,parentLayer Rhino.CurrentLayer(layername+"_"+parentLayer) End If End Function