Function SurfEvaluate Dim SurfObject: SurfObject = Rhino.GetObject("Select a surface",8) 'prompt the user to select a surface for the function dim i dim UvalOne(1), UvalTwo dim SurfaceUone, SurfaceVone dim PointOne, PointTwo dim Pt1, Pt2, Pt3, Pt4 dim NumVarU: NumVarU = 7 dim NumVarV: NumVarV = 9 dim FourPtCluster: FourPtCluster=Array(Pt1,Pt2,Pt3,Pt4) redim Matrix (NumVarU, NumVarV) dim tempPt SurfaceUone = array (0,0) SurfaceVone = array (0,0) 'test to be sure it is a surface, then find the domain in U and V If Rhino.IsSurface(SurfObject) Then SurfaceUone = Rhino.SurfaceDomain(SurfObject, 0) SurfaceVone = Rhino.SurfaceDomain(SurfObject, 1) 'Rhino.Print "Domain in U direction: " & CStr(SurfaceUone(0)) & " to " & CStr(SurfaceUone(1)) 'Rhino.Print "Domain in V direction: " & CStr(SurfaceVOne(0)) & " to " & CStr(SurfaceVOne(1)) End If 'create a 2-D array called Matrix to hold all the points along the surface 'the variables NumVarU and NumVarV determine the number of segments the 'surface will be divided into in each direction for i=0 to NumVarU for j=0 to NumVarV UvalOne(0)=((SurfaceUone(1)-SurfaceUone(0))/NumVarU)*(i) UvalOne(1)=((SurfaceVone(1)-SurfaceVone(0))/NumVarV)*(j) PointOne=Rhino.EvaluateSurface(SurfObject,UvalOne) tempPt = Rhino.addpoint(PointOne) 'creates points to mark the divisions Matrix(i,j) = PointOne 'creates a "master" array which will pass points to another function next next for i=0 to NumVarU-1 for j=0 to NumVarV-1 Pt1 = matrix(i,j) Pt2 = matrix(i+1,j) Pt3 = matrix(i+1,j+1) Pt4 = matrix(i,j+1) call DrawPyramid(Pt1,Pt2,Pt3,Pt4) next next end function Function DrawPyramid(Pt1,Pt2,Pt3,Pt4) 'this function draws a sufrace from 4 points, finds the center of that surface, 'then draws a line along the normal at this point in order to build surfaces 'up from base surface dim tempsrf, arrDomainU, arrDomainV, arrDirection dim arrParam(1),arrNormal,LineNormSmall, LineNormBig, arrPtDomain, arrPtParam dim Pt5, Pt6 dim sideone, sidetwo, sidethree, sidefour 'draw a surface using the four points passed from the Matrix tempsrf = rhino.addsrfpt (Array(pt1,pt2,pt3,pt4)) 'using the domain values for U an V, divide their difference by two 'to get array parameters, then evaluate the surface to find the midpoint arrDomainU = Rhino.SurfaceDomain(tempsrf, 0) arrDomainV = Rhino.SurfaceDomain(tempsrf, 1) arrParam(0) =(arrDomainU(1)-arrDomainU(0))/2 arrParam(1) =(arrDomainV(1)-arrDomainV(0))/2 Pt5 = Rhino.EvaluateSurface(tempsrf, arrParam) Rhino.AddPoint Pt5 'add a point at the center of tempsrf 'find the normal of the surface at Pt5 and draw a line, then extend the line arrNormal = Rhino.SurfaceNormal (tempSrf, arrParam) LineNormSmall = Rhino.AddLine (arrNormal(0), arrNormal(1)) 'LineNormBig = Rhino.ExtendCurveLength (LineNormSmall, 0,1,7*rnd) 'creates random height LineNormBig = Rhino.ExtendCurveLength (LineNormSmall, 0,1,10) 'reverse the direction of the surface in order to extrude in the opposite direction Rhino.SelectObject (tempsrf) Rhino.Command "Flip " arrNormal = Rhino.SurfaceNormal (tempSrf, arrParam) LineNormSmall = Rhino.AddLine (arrNormal(0), arrNormal(1)) Rhino.ExtrudeSurface tempSrf,LineNormSmall 'make a base from the surface 'make a new point using the domain of the extended line arrPtDomain = Rhino.CurveDomain(LineNormBig) arrPtParam = arrPtDomain(1) Pt6 = Rhino.EvaluateCurve(LineNormBig, arrPtParam) Rhino.AddPoint Pt6 'draw a pyramid w/ four sides using Points 1,2,3,4,and 6 sideone = rhino.addsrfpt (Array(pt1,pt2,pt6)) sidetwo = rhino.addsrfpt (Array(pt2,pt3,pt6)) sidethree = rhino.addsrfpt (Array(pt3,pt4,pt6)) sidefour = rhino.addsrfpt (Array(pt4,pt1,pt6)) End Function call SurfEvaluate