'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Octet-Truss-Generator ' ' by Taro Narahara '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim srf 'Surface Input srf=Rhino.GetObject("get surface", 8) Dim divX 'number of division in U Axis Dim divY 'number of division in V Axis divX=Rhino.GetInteger("input division on U Axis") divY=Rhino.GetInteger("input division on V Axis") Dim N 'Counter for the recursion N=1 Function SurfNetwork(srf) ReDim pt(divX,divY) surfU=Rhino.SurfaceDomain(srf, 0) 'int direction U=0 V=1 surfV=Rhino.SurfaceDomain(srf, 1) ReDim arrPara(divX,divY) For i=0 To divX For j=0 To divY Uval=((surfU(1)-surfU(0))/divX)*i Vval=((surfV(1)-surfV(0))/divY)*j pt(i,j)=evaluateSurface(srf, Array(Uval,Vval)) arrPara(i,j) = Rhino.SurfaceClosestPoint(srf, pt(i,j)) Next Next 'add isocurve on U axis For i=0 To divX Rhino.ExtractIsoCurve srf, arrPara(i,0), 1 Next 'add isocurve on V axis For j=0 To divY Rhino.ExtractIsoCurve srf, arrPara(0,j), 2 Next 'add Lines for Diagonal Bracings For i=0 To divX-1 For j=0 To divY-1 Rhino.AddLine pt(i,j), pt(i+1,j+1) Next Next Dim length length=Rhino.Distance(pt(0,0),pt(0,1)) Dim thickness thickness=length/10 'thickness is 1/20 of side length 1/12 used Dim srfOff srfOff=Rhino.OffsetSurface(srf, length) Rhino.DeleteObject(srf) ReDim pt2(divX,divY) ReDim arrPara2(divX,divY) Dim surfU2 Dim surfV2 surfU2=Rhino.SurfaceDomain(srfOff, 0) 'int direction U=0 V=1 surfV2=Rhino.SurfaceDomain(srfOff, 1) Dim Uval2 Dim Vval2 For i=0 To divX For j=0 To divY Uval2=((surfU2(1)-surfU2(0))/divX)*i Vval2=((surfV2(1)-surfV2(0))/divY)*j pt2(i,j)=evaluateSurface(srfOff, Array(Uval2,Vval2)) Rhino.AddLine pt(i,j), pt2(i,j) arrPara2(i,j) = Rhino.SurfaceClosestPoint(srfOff, pt(i,j)) Next Next For i=0 To divX For j=0 To divY If (i<>divX And j<>divY) Then Rhino.AddLine pt(i,j), pt2(i+1,j) Rhino.AddLine pt(i,j), pt2(i,j+1) Rhino.AddLine pt(i,j), pt2(i+1,j+1) End If Next Next For i=1 To divX For j=1 To divY Rhino.AddLine pt(divX,j-1), pt2(divX,j) Rhino.AddLine pt(i-1,divY), pt2(i,divY) Next Next Dim arraylines arraylines=Rhino.ObjectsByType (4, vbFalse) For i=0 To UBound(arraylines) Rhino.SelectObject (arraylines(i)) Rhino.command "_pipe _thick=no _cap=round " & thickness & " _enter" & " _enter" & " _enter" Rhino.UnselectObject(arraylines(i)) Next Rhino.DeleteObjects(arraylines) If N>0 Then 'N=1 to X number of recursion you want 'add isocurve on U axis For i=0 To divX Rhino.ExtractIsoCurve srfOff, arrPara2(i,0), 1 Next 'add isocurve on V axis For j=0 To divY Rhino.ExtractIsoCurve srfOff, arrPara2(0,j), 2 Next 'add Lines for Diagonal Bracings For i=0 To divX-1 For j=0 To divY-1 Rhino.AddLine pt2(i,j), pt2(i+1,j+1) Next Next Rhino.DeleteObject(srfOff) Dim arraylines2 arraylines2=Rhino.ObjectsByType (4, vbFalse) For i=0 To UBound(arraylines2) Rhino.SelectObject (arraylines2(i)) Rhino.command "_pipe _thick=no _cap=round " & thickness & " _enter" & " _enter" & " _enter" Rhino.UnselectObject(arraylines2(i)) Next Rhino.DeleteObjects(arraylines2) Rhino.print "finished" Else N=N+1 Rhino.print N Call SurfNetwork(srfOff) End If End Function Call SurfNetwork(srf) 'Dim arraylines3 'arraylines3=Rhino.ObjectsByType (4, vbFalse) 'For i=0 To UBound(arraylines3) 'Rhino.SelectObject (arraylines3(i)) 'Rhino.command "_pipe _thick=no _cap=round " & thickness & " _enter" & " _enter" & " _enter" 'Rhino.UnselectObject(arraylines3(i)) 'Next 'Rhino.DeleteObjects(arraylines)