Seroussi Pavillion

biothing_roof_001.jpgbiothing_roof_0021.jpgbiothing_roof_003.jpgbiothing_roof_004.jpg

Here are some images from a collaboration with biothing. My focus was on developing the outer tiling module. The facted skylight is modulated with intersecting sin wave functions in relation to nodes of interest distributed across the site.

biothing_roof_005.jpgelectric-line-charge-with-components-03-v3maxwell-r01.jpg

img_0211.jpgimg_0212.jpg

seroussi-house-r07-gf-pink.jpgseroussi-house-r08-gf-pink.jpgseroussi-house-r09-gf-pink.jpgseroussi-house-r10-gf-pink.jpg

roofplan.jpg

Rhinoscript


'component surface array

'cw wang'modified from

'skin panel prototype

'joshua vermillion

Dim sourceSurface, uDiv, vDiv, height, grid

Dim uStep, vStep

Dim uVal, vVal

Dim width

Dim depth

Dim  ap1,ap2,ap3,ap4,ap5

Dim  ap1n,ap2n,ap3n,ap4n,ap5n

Dim yTilt

Dim xTilt

Dim xTmin

Dim xTmax

Dim yTmin

Dim yTmax

Dim yStep

Dim offset

Dim splitWidth

Dim parentLayer

Dim midCurve

Dim midSurface

Dim componentColor : componentColor = RGB(125,125,125)

Dim underCocoon

Dim overCocoon

Dim court

Dim sinMult

Dim locator

Dim locatorMidDist

Sub panel

Dim i, j ,k

Dim sourceCurves

 'Prompt user for input data

 'sourceSurface = Rhino.GetObject("Select a surface to populate", 8,, True)

 parentLayer = Rhino.GetString("Enter layer number",1)

 sourceCurves = Rhino.GetObjects("Select curves", 4,, True)

Dim componentType : componentType =  Rhino.ListBox(Array("Exterior","Mesh"),"Select Component Type")

Dim vertBool	: vertBool = Rhino.GetBoolean("Build vertical?", Array("Build", "horizontal", "vertical"),Array(False))

 Dim louvres : louvres = Rhino.GetBoolean("Build courtyard louvres?", Array("Build", "no", "yes"),Array(False))

 locator= Rhino.GetPoint("select locator point")

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

 uDiv = 1

 If componentType = "Mesh"  Then

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

 	'	height = Rhino.GetReal("Enter a height multiplier ", 2)

 	height=2

 	'		xTmin =  Rhino.GetReal("Enter x tilt minimum(0-1)", .7)

 	'		xTmax =  Rhino.GetReal("Enter x tilt maximum(0-1)", .8)

 	'

 	'		yTmin =  Rhino.GetReal("Enter Y tilt minimum(0-1)", .4)

 	'		yTmax =  Rhino.GetReal("Enter Y tilt maximum(0-1)", .45)

 	'

 	xTmin = .7

 	xTmax =   .8

yTmin = .4

 	yTmax =.45

End If

If componentType = "Exterior"  Then

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

 	'vDiv=60

 	'height = Rhino.GetReal("Enter a height multiplier ", .2)

 	'sinMult = Rhino.GetReal("Enter a Sin multiplier ", 3)

 	sinMult =3

'splitWidth = Rhino.GetReal("Enter split width", 15)

 	splitWidth =15

 	'xTmin =  Rhino.GetReal("Enter x tilt minimum(0-1)", .1)

 	'xTmax =  Rhino.GetReal("Enter x tilt maximum(0-1)", .9)

 	xTmin=.1

 	xTmax=.9

 	'yTmin =  Rhino.GetReal("Enter Y tilt minimum(0-1)", .3)

 	'yTmax =  Rhino.GetReal("Enter Y tilt maximum(0-1)", .9)

 	yTmin=.2

 	yTmax=.9

 	'offset =  Rhino.GetReal("Enter component offset (0-1)", .05)

 	offset=.02

 	height =.1

End If

If componentType = "Transition"  Then

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

 	height = Rhino.GetReal("Enter a height multiplier ", .02)

splitWidth = Rhino.GetReal("Enter split width", 30)

 	'xTmin =  Rhino.GetReal("Enter x tilt minimum(0-1)", .1)

 	'xTmax =  Rhino.GetReal("Enter x tilt maximum(0-1)", .9)

 	xTmin=.2

 	xTmax=.5

 	'yTmin =  Rhino.GetReal("Enter Y tilt minimum(0-1)", .3)

 	'yTmax =  Rhino.GetReal("Enter Y tilt maximum(0-1)", .9)

 	yTmin=.9

 	yTmax=.9

 	'offset =  Rhino.GetReal("Enter component offset (0-1)", .05)

 	offset=.1

 End If

 If componentType = "Wall"  Then

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

 	height = Rhino.GetReal("Enter a height multiplier ", .4)

xTmin =  Rhino.GetReal("Enter x tilt minimum(0-1)", .1)

 	xTmax =  Rhino.GetReal("Enter x tilt maximum(0-1)", .8)

yTmin =  Rhino.GetReal("Enter Y tilt minimum(0-1)", .1)

 	yTmax =  Rhino.GetReal("Enter Y tilt maximum(0-1)", .8)

splitWidth = Rhino.GetReal("Enter split width", 8)

 	offset =  Rhino.GetReal("Enter component offset (0-1)", .05)

 End If

'Dim flip : flip = Rhino.GetBoolean("Flip U and V?", Array("Flip","U,V", "V,U"),Array(False))

 '	Dim showDraw : showDraw =  Rhino.GetBoolean("Show or Hide construction?", Array("Construction","Hide", "Show"), Array(True))

'loft curves

If vertBool(0)=True	 Then

 	ReDim sourceSurface(UBound(sourceCurves)-2)

Dim a: a=0

 	For i=0 To UBound(sourceSurface)

Dim scArrV : scArrV = Array(sourceCurves(i),sourceCurves(i+2))

 		CheckLayerParent "construction"

 		sourceSurface(i)  = Rhino.AddEdgeSrf(scArrV)

 		'sourceSurface(i)  =Rhino.AddLoftSrf (scArrV ,  ,  , 3 , 1 )

 		Rhino.Command "SelNone"

 		Rhino.LastCreatedObjects  True

 		Rhino.Command "Reparameterize 0 1 0 1 "

a=a+2

Next

Else

 	ReDim sourceSurface(UBound(sourceCurves)-1)

 	For i=0 To 	UBound(sourceSurface )

 		Dim scArr : scArr = Array(sourceCurves(i),sourceCurves(i+1))

CheckLayerParent "construction"

 		sourceSurface(i)  = Rhino.AddEdgeSrf(scArr)

Rhino.Command "SelNone"

 		Rhino.LastCreatedObjects  True

 		Rhino.Command "Reparameterize 0 1 0 1 "

Next

 End If

'	If cocoonBool(0) = True Then

 '

 '		For i=0 To UBound(sourceCurves)-1

 '			CheckLayerParent "construction"

 '			Dim sourceSurfaceM : sourceSurfaceM  = Rhino.AddEdgeSrf(Array(sourceCurves(1),sourceCurves(3)))

 '

 '			Rhino.Command "SelNone"

 '			Rhino.LastCreatedObjects  True

 '			Rhino.Command "Reparameterize 0 1 0 1 "

 '

 '			'		Dim arrDomU :	arrDomU = Rhino.SurfaceDomain(sourceSurfaceM, 0)

 '			'		Dim u0 :	u0 = arrDomU(0)+.5

 '			'		Dim u1 :	u1 = arrDomU(1)-.5

 '			'		Dim arrDomV:	arrDomV = Rhino.SurfaceDomain(sourceSurfaceM, 1)

 '			'		Dim v0:v0 = arrDomV(0)

 '			'		Dim v1: v1 = arrDomV(1)

 '			'		CheckLayerParent "construction"

 '			'		midCurve=Rhino.AddInterpCrvOnSrfUV(sourceSurfaceM,Array(Array(u0,v0), Array(u1,v1)))

 '			'

 '

 '			'

 '

 '

 '			'		For j=0 To 	UBound(midCurve)-1

 '			'			CheckLayerParent "construction"

 '			'			midSurface(j)  = Rhino.AddEdgeSrf(Array(midCurve(j),midCurve(j+1)))

 '			'			Rhino.Command "SelNone"

 '			'			Rhino.LastCreatedObjects  True

 '			'			Rhino.Command "Reparameterize 0 1 0 1 "

 '			'		Next

 '

 '			End If

ReDim ap1 ((uDiv-1),(vDiv-1))

 ReDim ap2 ((uDiv-1),(vDiv-1))

 ReDim ap3 ((uDiv-1),(vDiv-1))

 ReDim ap4 ((uDiv-1),(vDiv-1))

 ReDim ap5 ((uDiv-1),(vDiv-1))

ReDim ap1n ((uDiv-1),(vDiv-1))

 ReDim ap2n ((uDiv-1),(vDiv-1))

 ReDim ap3n ((uDiv-1),(vDiv-1))

 ReDim ap4n ((uDiv-1),(vDiv-1))

 ReDim ap5n ((uDiv-1),(vDiv-1))

ReDim underCocoon ((uDiv-1),(vDiv-1))

 ReDim overCocoon ((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

 	'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

 '	If showDraw(0) = False Then

 '		Rhino.EnableRedraw vbFalse

 '		Rhino.Print "Populating component..."

 '	End If

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

If componentType = "Wall"  Then

 	Dim UB : UB=	 UBound(sourceSurface)/2

Else

 	UB=	 UBound(sourceSurface)

 End If

For k = 0 To UB

 	yStep = 0

 	xStep = 0

For i = 0 To uDiv-1

 		For j = 0 To vDiv-1

'Find the 3D coordinate for each of the 4 corners of the tile using the UV coordinates as input

 			Dim topLeft :topLeft=	Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)))

 			Dim topRight : topRight = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+1, vVal(j)))

 			Dim bottomLeft : bottomLeft = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j+1)))

width =  Rhino.Distance(topLeft,topRight)

 			depth =  Rhino.Distance(topLeft,bottomLeft)

Dim curveMid:CurveMid=Rhino.EvaluateSurface(sourceSurface(k),Array(uVal(uDiv/2), vVal(vDiv/2)))

 			locatorMidDist=Rhino.Distance(Array(curveMid(0),curveMid(1),curveMid(2)),locator)

If componentType = "Wall"  Then

 				Dim top :top=	Rhino.EvaluateSurface(sourceSurface(k*2), Array(uVal(i), vVal(j)))

 				Dim bottom : bottom = Rhino.EvaluateSurface(sourceSurface(k*2+1),Array(uVal(i), vVal(j)))

 				height=Rhino.Distance(top,bottom)

 				wallComponent i,j,k*2,sourceSurface

End If

If componentType = "Mesh"  Then

meshComponent i,j,k,sourceSurface

End If

'					For m = 0 To 1

 			'						height=height*-1

 			'

If componentType = "Exterior" Or componentType="Transition"  Then

If width >splitWidth Then

 					For p=0 To 1

 						uVal(0)=p/2

 						uVal(1)=1/2

 						extComponent i,j,k

 					Next

 				End If

If width

If louvres(0)=True   Then

 						louvreComponent i,j,k

 						louvres(0)=False

 					Else

uVal(0)=0

 						uVal(1)=1

 						extComponent i,j,k

End If

Else

 					If width 

 						uVal(0)=0

 						uVal(1)=1

 						extComponent i,j,k

 					End If

End If

 			End If

Next

 	Next

 Next

Rhino.DeleteObjects (sourceSurface)

Dim YN2:YN2= Rhino.MessageBox ("Delete construction lines?"  , 4)

 If YN2 =6 Then

 	Rhino.PurgeLayer ("construction")

 	'			Rhino.DeleteObjects(underCocoon(0,RandomNumber(0,UBound(underCocoon))))

 	'			Rhino.DeleteObjects(overCocoon(0,RandomNumber(0,UBound(overCocoon))))

 End If

End Sub

panel

Function cocoonComponent (i,j,k,surfaceA)

 checkLayerParent(parentLayer)

yTilt = Sin(j/vDiv)

If yTilt>yTmax Then

 	yTilt = yTmax

 End If

 If yTilt

yTilt = yTmin

 End If

xTilt = Sin(j/vDiv)

If xTilt>xTmax Then

 	xTilt = xTmax

 End If

If xTilt

 	xTilt = xTmin

 End If

Dim overC : overC = RGB(125,125,125)

Dim a0 : a0 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i), vVal(j)))

 Dim c0 : c0 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i)+uVal(1), vVal(j)))

 Dim c2 : c2 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i)+uVal(1), vVal(j+1)))

 Dim a2 : a2 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i), vVal(j+1)))

Dim b1 : b1 = Rhino.SurfaceCurvature(surfaceA(k), Array(uVal(i)+(uVal(1)*.5), vVal(j) + vVal(1)*(1-xTilt)))

 ap1(i,j) = offsetCalc(b1, height*.1)

 Dim bb1 : bb1 = Rhino.SurfaceCurvature(surfaceA(k), Array(uVal(i)+(uVal(1)*.5), vVal(j)+vVal(1)*xTilt ))

 ap2(i,j) = offsetCalc(bb1, height*.1)

ap3(i,j) = offsetCalc(b1, height/2)

 ap4(i,j) = offsetCalc(bb1, height/2)

Dim a0B : a0B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i), vVal(j)))

 Dim c0B : c0B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i)+uVal(1), vVal(j)))

 Dim c2B : c2B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i)+uVal(1), vVal(j+1)))

 Dim a2B : a2B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i), vVal(j+1)))

Dim b1B : b1B = Rhino.SurfaceCurvature(surfaceA	(k+1), Array(uVal(i)+(uVal(1)*.5), vVal(j) + vVal(1)*(1-xTilt)))

 ap1n(i,j) = offsetCalc(b1B, -height*.1)

Dim bb1B : bb1B = Rhino.SurfaceCurvature(surfaceA(k+1), Array(uVal(i)+(uVal(1)*.5), vVal(j)+vVal(1)*xTilt))

 ap2n(i,j) = offsetCalc(bb1B, -height*.1)

'based on curvature

 'ap1(i,j) = offsetCalc(cb2, height*cb2(7)*10)

 'ap2(i,j) = offsetCalc(cb4, height*cb4(7)*10)

'constant height

 'ap1(i,j) = offsetCalc(cb2, height)

 'ap2(i,j) = offsetCalc(cb4, height)

'based on width height

 'xTilt=.1

'	ap2(i,j) = offsetCalc(c0, height*(1-yTilt))

 '	ap3(i,j) = offsetCalc(d0, height*xTilt)

 '	ap4(i,j) = offsetCalc(e0, height*(1-yTilt))

 '	ap5(i,j) = offsetCalc(f0, height*yTilt)

 '

 '	ap1n(i,j) = offsetCalc(b1, height*yTilt)

 '	ap2n(i,j) = offsetCalc(c1, height*(1-yTilt))

 '	ap3n(i,j) = offsetCalc(d1, height)

 '	ap4n(i,j) = offsetCalc(e1, height*(1-yTilt))

 '	ap5n(i,j) = offsetCalc(f1, height*yTilt)

CheckLayerParent "construction"

 'Dim a2ap1c0 : a2ap1c0 = Rhino.AddArc3Pt(a2,c0,ap1(i,j))

 'Dim c4ap4e2 : c4ap4e2 = Rhino.AddArc3Pt(c4,e2,ap4(i,j))

 'Dim a0ap1ap2b3 : a0ap1ap2b3 = Rhino.AddNurbsCurve (Array(a0,ap1(i,j),ap2(i,j),b3),Array(-1,-.5,0,.5,1) ,2,Array(100,1,1,100))

 'Dim a0nap1fnap2fnb3n : a0nap1fnap2fnb3n = Rhino.AddNurbsCurve (Array(a0n,ap1fn(i,j),ap2fn(i,j),b3n),Array(-1,-.5,0,.5,1) ,2,Array(100,1,1,100))

'Dim a2ap1c0 : a2ap1c0 = Rhino.AddEllipse3Pt (a2,c0,ap1(i,j))

 'Dim c4ap4e2 : c4ap4e2 = Rhino.AddEllipse3Pt (c4,e2,ap4(i,j))

'	Dim a0a1: a0a1 = Rhino.AddLine(a0,a1)

'horiz

 'top

 Dim a0ap1c0 : a0ap1c0 = Rhino.AddNurbsCurve (Array(a0,ap1(i,j),c0),Array(0,0,1,1) ,2,Array(100,100,100))

 'bottom

 Dim a0Bap1nc0B : a0Bap1nc0B = Rhino.AddNurbsCurve (Array(a0B,ap1n(i,j),c0B),Array(0,0,1,1) ,2,Array(100,100,100))

 'vert

 'left

 Dim a0ap3a0B :  a0ap3a0B = 	Rhino.AddNurbsCurve (Array(a0,ap3(i,j),a0B),Array(0,0,1,1) ,2,Array(100,100,100))

 'right

 Dim c0ap3c0B :  c0ap3c0B = 	Rhino.AddNurbsCurve (Array(c0,ap3(i,j),c0B),Array(0,0,1,1) ,2,Array(100,100,100))

'horiz

 'top

 Dim a2ap2c2 : a2ap2c2 = Rhino.AddNurbsCurve (Array(a2,ap2(i,j),c2),Array(0,0,1,1) ,2,Array(100,100,100))

 'bottom

 Dim a2Bap2nc2B : a2Bap2nc2B = Rhino.AddNurbsCurve (Array(a2B,ap2n(i,j),c2B),Array(0,0,1,1) ,2,Array(100,100,100))

'vert

 'left

 Dim a2ap4a2B :  a2ap4a2B = 	Rhino.AddNurbsCurve (Array(a2,ap4(i,j),a2B),Array(0,0,1,1) ,2,Array(100,100,100))

 'right

 Dim c2ap4c2B :  c2ap4c2B = 	Rhino.AddNurbsCurve (Array(c2,ap4(i,j),c2B),Array(0,0,1,1) ,2,Array(100,100,100))

CheckLayer"Cocoon Component" , overC

 'overCocoon(i,j)=Rhino.AddLoftSrf(Array(a0a1,ap1ap1n,ap2ap2n,ap3ap3n))

'underCocoon(i,j)=Rhino.AddLoftSrf(Array(ap3ap3n,ap4ap4n,ap5ap5n,g0g1))

'	Rhino.AddEdgeSrf(Array(a0ap1c0, a0Bap1nc0B,a0ap3a0B, c0ap3c0B))

 '	Rhino.AddEdgeSrf(Array(a2ap2c2, a2Bap2nc2B,a2ap4a2B, c2ap4c2B))

 '	edgeSurface a0ap1c0,  a2ap2c2

 '	edgeSurface a0Bap1nc0B,  a2Bap2nc2B

 '	edgeSurface a0ap3a0B,  a2ap4a2B

 '	edgeSurface c0ap3c0B,  c2ap4c2B

'Rhino.AddLoftSrf Array(	a0ap3a0B, c0ap3c0B,c2ap4c2B,a2ap4a2B),,,,,,True

 edgeSurface  a0ap1c0, a2ap4a2B

edgeSurface   a2Bap2nc2B, c0ap3c0B

End Function

Function meshComponent (i,j,k,surface)

checkLayerParent(parentLayer)

yTilt = Sin(j/vDiv)

If yTilt>yTmax Then

 	yTilt = yTmax

 End If

 If yTilt

yTilt = yTmin

 End If

xTilt = Sin(1-j/vDiv)

If xTilt>xTmax Then

 	xTilt = xTmax

 End If

If xTilt

xTilt = xTmin

 End If

Dim overC : overC = RGB(125,125,125)

Dim a0 : a0 = Rhino.EvaluateSurface(surface(k), Array(uVal(i), vVal(j)))

 Dim g0 : g0 = Rhino.EvaluateSurface(surface(k), Array(uVal(i)+uVal(1), vVal(j)))

 Dim g1 : g1 = Rhino.EvaluateSurface(surface(k), Array(uVal(i)+uVal(1), vVal(j+1)))

 Dim a1 : a1 = Rhino.EvaluateSurface(surface(k), Array(uVal(i), vVal(j+1)))

Dim b0 : b0 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*.05), vVal(j)))

 Dim c0 : c0 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*yTilt), vVal(j)+vVal(1)*xTilt))

Dim d0 : d0 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*.5), vVal(j)))

 Dim e0 : e0 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*(1-yTilt)), vVal(j)+vVal(1)*xTilt))

Dim f0 : f0 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*.95), vVal(j)))

Dim b1 : b1 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*.05), vVal(j+1)))

 Dim c1 : c1 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*yTilt), vVal(j+1)-vVal(1)*xTilt))

Dim d1 : d1 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*.5), vVal(j+1)))

 Dim e1 : e1 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*(1-yTilt)), vVal(j+1)-vVal(1)*xTilt))

Dim f1 : f1 = Rhino.SurfaceCurvature(surface(k), Array(uVal(i)+(uVal(1)*.95), vVal(j+1)))

ap1(i,j) = offsetCalc(b0, height*yTilt)

 ap2(i,j) = offsetCalc(c0, height*(1-yTilt))

 ap3(i,j) = offsetCalc(d0, height)

 ap4(i,j) = offsetCalc(e0, height*(1-yTilt))

 ap5(i,j) = offsetCalc(f0, height*yTilt)

ap1n(i,j) = offsetCalc(b1, height*yTilt)

 ap2n(i,j) = offsetCalc(c1, height*(1-yTilt))

 ap3n(i,j) = offsetCalc(d1, height)

 ap4n(i,j) = offsetCalc(e1, height*(1-yTilt))

 ap5n(i,j) = offsetCalc(f1, height*yTilt)

CheckLayerParent "construction"

Dim a0a1: a0a1 = Rhino.AddLine(a0,a1)

 Dim ap1ap1n:ap1ap1n = Rhino.AddLine(ap1(i,j),ap1n(i,j))

 Dim ap2ap2n:ap2ap2n = Rhino.AddLine(ap2(i,j),ap2n(i,j))

 Dim ap3ap3n:ap3ap3n = Rhino.AddLine(ap3(i,j),ap3n(i,j))

 Dim ap4ap4n:ap4ap4n = Rhino.AddLine(ap4(i,j),ap4n(i,j))

 Dim ap5ap5n:ap5ap5n = Rhino.AddLine(ap5(i,j),ap5n(i,j))

 Dim g0g1:g0g1 = Rhino.AddLine(g0,g1)

CheckLayer"Cocoon Component" , overC

 overCocoon(i,j)=Rhino.AddLoftSrf(Array(a0a1,ap1ap1n,ap2ap2n,ap3ap3n))

 underCocoon(i,j)=Rhino.AddLoftSrf(Array(ap3ap3n,ap4ap4n,ap5ap5n,g0g1))

End Function

Function wallComponent(i,j,k,surfaceA)

checkLayerParent(parentLayer)

yTilt = Sin(j/vDiv)

If yTilt>yTmax Then

 	yTilt = yTmax

 End If

 If yTilt

yTilt = yTmin

 End If

xTilt = Sin(j/vDiv)

If xTilt>xTmax Then

 	xTilt = xTmax

 End If

If xTilt

 	xTilt = xTmin

 End If

wallComponent

Dim overC : overC = RGB(125,125,125)

Dim a0 : a0 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i), vVal(j)))

 Dim c0 : c0 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i)+uVal(1), vVal(j)))

 Dim c2 : c2 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i)+uVal(1), vVal(j+1)))

 Dim a2 : a2 = Rhino.EvaluateSurface(surfaceA(k), Array(uVal(i), vVal(j+1)))

Dim b1 : b1 = Rhino.SurfaceCurvature(surfaceA(k), Array(uVal(i)+(uVal(1)*.5), vVal(j) + vVal(1)*(1-xTilt)))

 ap1(i,j) = offsetCalc(b1, height*.1)

 Dim bb1 : bb1 = Rhino.SurfaceCurvature(surfaceA(k), Array(uVal(i)+(uVal(1)*.5), vVal(j)+vVal(1)*xTilt ))

 ap2(i,j) = offsetCalc(bb1, height*.1)

ap3(i,j) = offsetCalc(b1, height/2)

 ap4(i,j) = offsetCalc(bb1, height/2)

Dim a0B : a0B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i), vVal(j)))

 Dim c0B : c0B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i)+uVal(1), vVal(j)))

 Dim c2B : c2B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i)+uVal(1), vVal(j+1)))

 Dim a2B : a2B = Rhino.EvaluateSurface(surfaceA(k+1), Array(uVal(i), vVal(j+1)))

Dim b1B : b1B = Rhino.SurfaceCurvature(surfaceA	(k+1), Array(uVal(i)+(uVal(1)*.5), vVal(j) + vVal(1)*(1-xTilt)))

 ap1n(i,j) = offsetCalc(b1B, -height*.1)

Dim bb1B : bb1B = Rhino.SurfaceCurvature(surfaceA(k+1), Array(uVal(i)+(uVal(1)*.5), vVal(j)+vVal(1)*xTilt))

 ap2n(i,j) = offsetCalc(bb1B, -height*.1)

CheckLayerParent "construction"

'horiz

 'top

 Dim a0ap1c0 : a0ap1c0 = Rhino.AddNurbsCurve (Array(a0,ap1(i,j),c0),Array(0,0,1,1) ,2,Array(100,100,100))

 'bottom

 Dim a0Bap1nc0B : a0Bap1nc0B = Rhino.AddNurbsCurve (Array(a0B,ap1n(i,j),c0B),Array(0,0,1,1) ,2,Array(100,100,100))

 'vert

 'left

 Dim a0ap3a0B :  a0ap3a0B = 	Rhino.AddNurbsCurve (Array(a0,ap3(i,j),a0B),Array(0,0,1,1) ,2,Array(100,100,100))

 'right

 Dim c0ap3c0B :  c0ap3c0B = 	Rhino.AddNurbsCurve (Array(c0,ap3(i,j),c0B),Array(0,0,1,1) ,2,Array(100,100,100))

'horiz

 'top

 Dim a2ap2c2 : a2ap2c2 = Rhino.AddNurbsCurve (Array(a2,ap2(i,j),c2),Array(0,0,1,1) ,2,Array(100,100,100))

 'bottom

 Dim a2Bap2nc2B : a2Bap2nc2B = Rhino.AddNurbsCurve (Array(a2B,ap2n(i,j),c2B),Array(0,0,1,1) ,2,Array(100,100,100))

'vert

 'left

 Dim a2ap4a2B :  a2ap4a2B = 	Rhino.AddNurbsCurve (Array(a2,ap4(i,j),a2B),Array(0,0,1,1) ,2,Array(100,100,100))

 'right

 Dim c2ap4c2B :  c2ap4c2B = 	Rhino.AddNurbsCurve (Array(c2,ap4(i,j),c2B),Array(0,0,1,1) ,2,Array(100,100,100))

CheckLayer"Cocoon Component" , overC

edgeSurface  a0ap1c0, a2ap4a2B

 edgeSurface   a2Bap2nc2B, c0ap3c0B

End Function

Function extComponent (i,j,k)

 checkLayerParent(parentLayer)

Dim ySin:ySin = Abs(Sin(sinMult*j/vDiv))

 Dim xSin:xSin = Abs(Sin(sinMult*j/vDiv))

Dim glassColor : glassColor = RGB(127,255,191 )

 Dim a0 : a0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)))

Dim dist : dist=Rhino.Distance(Array(a0(0),a0(1),a0(2)),locator)

Dim arrNormal:arrNormal = Rhino.SurfaceNormal(sourceSurface(k), Array(uVal(i), vVal(j)))

 CheckLayerParent "construction"

Rhino.addline Array(0,0,0),arrNormal

 Rhino.addline a0,locator

 Dim angle:angle=Rhino.Angle2(Array(a0,locator),Array(Array(0,0,0),arrNormal))

 'xTilt=1- locatorMidDist/dist

 'yTilt=1-locatorMidDist/dist

xTilt=angle(0)/30

 yTilt=angle(0)/30

 Rhino.Print "x"& xTilt

 Rhino.Print "y"& yTilt

If yTilt>yTmax Then

 	yTilt = yTmax

 End If

 If yTilt

 	yTilt = yTmin

 End If

If xTilt>xTmax Then

 	xTilt = xTmax

 End If

If xTilt

 	xTilt = xTmin

 End If

Dim f0 : f0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(j)))

 Dim a5 : a5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)+ vVal(1)))

Dim c0 : c0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(xTilt)), vVal(j)))

 Dim e0 : e0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-offset)), vVal(j)))

Dim a1 : a1 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)+vVal(1)*(offset)))

Dim a2 : a2 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)+vVal(1)*(yTilt)))

 Dim b2 : b2 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(offset)) , vVal(j)+vVal(1)*(yTilt)))

Dim b5 : b5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(offset)) , vVal(j)+vVal(1)))

 Dim d5 : d5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-xTilt)) , vVal(j)+vVal(1)))

Dim e3 : e3 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-offset)), vVal(j)+vVal(1)*(1-yTilt)))

 Dim f3 : f3 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(j)+vVal(1)*(1-yTilt)))

 Dim f4 : f4 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(j)+vVal(1)*(1-offset)))

Dim f5 : f5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(j)+vVal(1)))

Dim cc1 : cc1 = Rhino.SurfaceCurvature(sourceSurface(k), Array(uVal(i)+(uVal(1)*(xTilt)), vVal(j)+(vVal(1)*offset)))

 Dim cd4 : cd4 = Rhino.SurfaceCurvature(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-xTilt)), vVal(j)+vVal(1)*(1-offset)))

'based on width height

height=xTilt/10

 ap1(i,j) = offsetCalc(cc1,  width*height)

 ap2(i,j) = offsetCalc(cd4,  width*height)

Dim arrVertices(15)

 arrVertices(0) = a0

 arrVertices(1) = c0

 arrVertices(2) = e0

 arrVertices(3) = f0

 arrVertices(4) = a1

 arrVertices(5) = ap1(i,j)

 arrVertices(6) = a2

 arrVertices(7) =b2

 arrVertices(8) =e3

 arrVertices(9) =f3

 arrVertices(10) =ap2(i,j)

 arrVertices(11) =f4

 arrVertices(12) =a5

 arrVertices(13) =b5

 arrVertices(14) =d5

 arrVertices(15) =f5

Dim arrFaceVertices(7)

 arrFaceVertices(0) = Array(0,1,5,4)

 arrFaceVertices(1) = Array(1,2,8,5)

 arrFaceVertices(2) = Array(2,3,9,8)

 arrFaceVertices(3) = Array(4,5,7,6)

 arrFaceVertices(4) = Array(8,9,11,10)

 arrFaceVertices(5) = Array(6,7,13,12)

 arrFaceVertices(6) = Array(7,10,14,13)

 arrFaceVertices(7) = Array(10,11,15,14)

CheckLayer"Component" , componentColor

 Rhino.AddMesh arrVertices, arrFaceVertices

Dim arrGlassVertices(1)

 arrGlassVertices		(0) = Array(5,8,10,10)

 arrGlassVertices(1) = Array(5,7,10,10)

CheckLayer"Component Glass" , glassColor

 Rhino.AddMesh arrVertices, arrGlassVertices

End Function

Function louvreComponent (i,j,k)

 checkLayerParent(parentLayer)

yTilt = Sin(5*j/vDiv)

If yTilt>yTmax Then

 	yTilt = yTmax

 End If

 If yTilt

yTilt = yTmin

 End If

xTilt = Sin(5*j/vDiv)

If xTilt>xTmax Then

 	xTilt = xTmax

 End If

If xTilt

 	xTilt = xTmin

 End If

Dim glassColor : glassColor = RGB(127,255,191 )

 Dim a0 : a0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)))

 Dim f0 : f0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(j)))

 Dim a5 : a5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(vDiv)))

Dim c0 : c0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(xTilt)), vVal(j)))

 Dim e0 : e0 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-offset)), vVal(j)))

Dim a1 : a1 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)+vVal(1)*(offset)))

Dim a2 : a2 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i), vVal(j)+vVal(1)*(yTilt)))

 Dim b2 : b2 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(offset)) , vVal(j)+vVal(1)*(yTilt)))

Dim b5 : b5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(offset)) , vVal(vDiv)))

 Dim d5 : d5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-xTilt)) , vVal(vDiv)))

Dim e3 : e3 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-offset)), vVal(vDiv-1)+vVal(1)*(-yTilt)))

 Dim f3 : f3 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(vDiv)+vVal(1)*(-yTilt)))

 Dim f4 : f4 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(vDiv)+vVal(1)*(-offset)))

Dim f5 : f5 = Rhino.EvaluateSurface(sourceSurface(k), Array(uVal(i)+uVal(1), vVal(vDiv)))

Dim cc1 : cc1 = Rhino.SurfaceCurvature(sourceSurface(k), Array(uVal(i)+(uVal(1)*(xTilt)), vVal(j)+(vVal(1)*offset)))

 Dim cd4 : cd4 = Rhino.SurfaceCurvature(sourceSurface(k), Array(uVal(i)+(uVal(1)*(1-xTilt)), vVal(vDiv)+vVal(1)*(-offset)))

'based on width height

ap1(i,j) = offsetCalc(cc1,  height*2)

 ap2(i,j) = offsetCalc(cd4,  height*2)

CheckLayerParent "construction"

 Dim a0c0 : a0c0 = Rhino.AddLine(a0 , c0)

 Dim a1ap1 : a1ap1 = Rhino.AddLine(a1, ap1(i,j))

 Dim c0ap1 : c0ap1 = Rhino.AddLine(c0, ap1(i,j))

 Dim a0a1 : a0a1 = Rhino.AddLine(a0 , a1)

 Dim a2b2 : a2b2 = Rhino.AddLine(a2 , b2)

 Dim a2a5 : a2a5 = Rhino.AddLine(a2 ,a5)

 Dim b2b5 : b2b5 = Rhino.AddLine(b2 , b5)

 Dim d5ap2 : d5ap2= Rhino.AddLine(d5,ap2(i,j))

 Dim b2ap2 : b2ap2  = Rhino.AddLine(b2,ap2(i,j))

 Dim b5d5 : b5d5 =  Rhino.AddLine(b5 , d5)

 CheckLayer"Component" , componentColor

 edgeSurface a0c0,a1ap1

 edgeSurface a1ap1,a2b2

 edgeSurface a2a5,b2b5

 edgeSurface b2ap2,b5d5

 CheckLayerParent "construction"

 Dim d5f5 : d5f5 = Rhino.AddLine(d5 , f5)

 Dim e3f3 : e3f3 = Rhino.AddLine(e3 , f3)

 Dim e0f0 : e0f0 = Rhino.AddLine(e0 , f0)

 Dim e0e3 : e0e3 = Rhino.AddLine(e0 , e3)

 Dim f0f3 : f0f3 = Rhino.AddLine(f0 , f3)

 Dim c0e0 : c0e0 = Rhino.AddLine(c0 , e0)

 Dim f4ap2 : f4ap2 = Rhino.AddLine(f4 , ap2(i,j))

 Dim e3ap1 : e3ap1 = Rhino.AddLine( ap1(i,j), e3)

 CheckLayer"Component" , componentColo

 edgeSurface f4ap2,e3f3

 edgeSurface e0e3,f0f3

 edgeSurface f4ap2,d5f5

 edgeSurface c0e0,e3ap1

 CheckLayerParent "construction"

 Dim ap1ap2 : ap1ap2 = Rhino.AddLine(ap1(i,j) , ap2(i,j))

 Dim e3ap2 : e3ap2 = Rhino.AddLine( ap2(i,j), e3)

 Dim b2ap1 : b2ap1  = Rhino.AddLine(b2,ap1(i,j))

 CheckLayer "Component Glass",glassColor

 Rhino.AddPlanarSrf(Array(ap1ap2,e3ap2,e3ap1))

 Rhino.AddPlanarSrf(Array(ap1ap2,b2ap2,b2ap1))

End Function

Function edgeSurface(edge1,edge2)

Dim f : f = Rhino.CurveDirectionsMatch(edge1,edge2)

 Dim rEdge

If f = False Then

 	rEdge=	Rhino.ReverseCurve(edge2)

 End If

 Rhino.AddEdgeSrf(Array(edge1, edge2 ))

End Function

Function RandomNumber(nMin, nMax)

 RandomNumber = vbNull

 If Not IsNumeric(nMin) Then Exit Function

 If Not IsNumeric(nMax) Then Exit Function

 If nMin >= nMax Then Exit Function

 Randomize

 RandomNumber = Int((nMax - nMin + 1) * Rnd + nMin)

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)

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 CheckLayerParent(layername)

 If Rhino.IsLayer(layername) Then

 	Rhino.CurrentLayer(layername)

Else

 	Rhino.AddLayer layername,RGB(Cint(parentLayer*5),125,125)

 	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

Function mesh()

 Rhino.Command "SelNone"

 Rhino.Command "Sellast"

 Rhino.Command "_mesh           Enter"

End Function