''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Recursive Generation of surface ' ' January 2006 ' ' by Taro Narahara ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'generate input srface Function makeCurves() Dim crvOnePt1, crvOnePt2, crvOnePt3, crvOnePt4 'Define the variables for each point of curve one Dim crvTwoPt1, crvTwoPt2, crvTwoPt3, crvTwoPt4 'Define the variables for each point of curve two Dim crvOne, crvTwo 'Define variables for curves crvOnePt1 = Array(0.0, 0.0, 15.0) 'create three floats that are the (X,Y,Z) values of the point crvOnePt2 = Array(4.0, 0.0, 5.0) crvOnePt3 = Array(8.0, 0.0, 15.0) crvOnePt4 = Array(12.0, 0.0, 5.0) crvTwoPt1 = Array(0.0, 25, 5.0) 'create three floats that are the (X,Y,Z) values of the point crvTwoPt2 = Array(4.0, 25, 15.0) crvTwoPt3 = Array(8.0, 25, 5.0) crvTwoPt4 = Array(12.0, 25, 15.0) crvOne = Rhino.AddInterpCurve(Array(crvOnePt1, crvOnePt2, crvOnePt3, crvOnePt4)) 'Create first curve with array of points crvTwo = Rhino.AddInterpCurve(Array(crvTwoPt1, crvTwoPt2, crvTwoPt3, crvTwoPt4)) 'Create second curve with array of points Dim lines2lo lines2=Array(crvOne,crvTwo) Dim srf srf=Rhino.AddEdgeSrf(lines2) Rhino.DeleteObject(crvOne) Rhino.DeleteObject(crvTwo) Call splitPlane(srf) 'Rhino.sleep 1000 End Function '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Function splitPlane(srf) ReDim pt(3,3) surfU=Rhino.SurfaceDomain(srf, 0) 'int direction U=0 V=1 surfV=Rhino.SurfaceDomain(srf, 1) For i=0 To 2 For j=0 To 2 Uval=((surfU(1)-surfU(0))/2)*i Vval=((surfV(1)-surfV(0))/2)*j pt(i,j)=evaluateSurface(srf, Array(Uval,Vval)) Next Next ReDim newsrf(2,2) For i=0 To 1 For j=0 To 1 Dim points points=Array(pt(i,j),pt(i,j+1),pt(i+1,j+1),pt(i+1,j)) newsrf(i,j)=Rhino.AddSrfPt(points) Dim ptArray ptArray = Rhino.BoundingBox(newsrf(i,j)) Rhino.DeleteObject(newsrf(i,j)) newsrf(i,j) = Rhino.AddSrfPt(Array(ptArray(4),ptArray(1),ptArray(6),ptArray(3))) Next Next 'Making OVERLAP for physical 3D-printout Dim scalefactor scalefactor=Array(1.02, 1.02, 1.02) 'Scale 102% from corner Rhino.ScaleObject newsrf(0,0), pt(0,0), scalefactor Rhino.ScaleObject newsrf(1,0), pt(2,0), scalefactor Rhino.ScaleObject newsrf(0,1), pt(0,2), scalefactor Rhino.ScaleObject newsrf(1,1), pt(2,2), scalefactor Rhino.DeleteObject(srf) 'number of iteration you want If(Rhino.Distance(pt(1,1),pt(1,2))<1)Then '1:minimum size of surf you want Rhino.print "finished" Else Call splitPlane(newsrf(0,0)) Call splitPlane(newsrf(1,1)) End If End Function '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Function ExtrudeSrf() 'Rhino.BOundingBox returns to me an array of points ' 0 1 2 3 4 5 6 7 'boundBoxPts = Array(pt1, pt2, pt3, pt4, pt5, pt6, pt7, pt8) Dim arraysrf Dim boundBoxPts arraysrf= AllObjects() boundBoxPts = Rhino.BOundingBox(arraysrf) Call Rhino.SelectObjects(arraysrf) Rhino.Print"finish3" 'Loop through all the surface for extrusion 'find depth for extrusion relative to the siza of surf For i=0 To UBound(arraysrf) boundBoxPts = Rhino.BOundingBox(arraysrf(i)) Dim pt1 Dim pt2 Dim pt3 Dim path Dim length pt1= boundBoxPts(0) pt2=pt1 pt3= boundBoxPts(1) length=Rhino.Distance(pt1,pt3) pt2(2)=pt2(2)+length/5 '/5=ratio of the extrusion relative to the size of the surface path=Rhino.AddLine(pt2,pt1) Rhino.ExtrudeSurface arraysrf(i), path, vbTrue 'Surface is now extrude in the direction of the path Rhino.DeleteObject (path) Next End Function ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Function mirrorObj() Dim arrObjects, arrStartPt, arrEndPt Dim arrayshapes Dim boundBoxPts arrayshapes= AllObjects() boundBoxPts = Rhino.BOundingBox(arrayshapes) Call Rhino.SelectObjects(arrayshapes) If IsArray(arrayshapes) Then If IsArray(boundBoxPts) Then 'And IsArray(arrEndPt) Then Rhino.MirrorObjects arrayshapes, boundBoxPts(1), boundBoxPts(7), vbTrue End If End If End Function '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'excute functions makeCurves Extrudesrf mirrorObj