Pages of Code / RVB / Back

------------------------------------

070919_Search…

 

http://ncertainties.files.wordpress.com/2007/09/070922_nearest_004_pshop.jpg?w=500

http://ncertainties.files.wordpress.com/2007/09/070922_nearest_005_pshop.jpg?w=500 

Option Explicit
‘Script written by <Marc Fornes>
‘Script copyrighted by <Marc Fornes / theverymany.net>
‘Script version 13 September 2007 16:05:03

Call Main()
Sub Main()
 
 Dim i,j,k
 Dim arrPt
 
 Dim dblLow : dblLow = -5
 Dim dblUp : dblUp = 10

 Dim arrPts()

 Dim n : n = 0

 Call rhino.enableRedraw(False)

 ’ ===========================

 For i = 0 To 5

  For j = 0 To 5

   For k = 0 To 5

    ReDim Preserve arrpts(n)

    arrPts(n) = array(random(dblLow, dblUp),random(dblLow, dblUp),random(dblLow, k*dblUp))

    Call rhino.AddPoint (arrPts(n))

    If n >= 2 Then

     Dim arrPtNearer : arrPtNearer = functNearestNeighbor(arrPts, n)

     Dim strLine : strLine = rhino.addLine(arrPts(n), arrPtNearer)

     Call Rhino.AddCone (arrPts(n), arrPtNearer, 0.2)

     call rhino.addSphere (arrPts(n), 0.2)

    End If

    n = n + 1   

   Next 

  Next

 Next

 ’ ===========================

 Call rhino.enableRedraw(True)
 

End Sub

 

070921_HoneyCombLocators

http://ncertainties.files.wordpress.com/2007/09/070912_hcombattrac_001_03_p.jpg?w=500

http://ncertainties.files.wordpress.com/2007/09/070912_hcomb_001_02_pshop.jpg?w=500

http://ncertainties.files.wordpress.com/2007/09/070912_hcombattrac_001_01_p.jpg?w=500 

Option Explicit
‘Script written by Mark Bearak
‘Script version Tuesday, September 18, 2007 1:26:12 PM

Call Main()
Sub Main()
Dim arrStrAttractors : arrStrAttractors = Rhino.GetObjects (“”select the attractors”, 1)
Dim intXMax : intXMax = Rhino.GetInteger (“how many in x?”, 30)
Dim intYMax : intYMax = Rhino.GetInteger (“how many in y?”, 30)
Dim d : d = Rhino.GetInteger (“max distance of falloff?”, 15)
Dim Color : Color = 255
Dim c : c = Color/d
ReDim arrAttractors(UBound(arrStrAttractors))
Dim strAttractor, k

k=0
For Each strAttractor In arrStrAttractors
arrAttractors(k)    = Rhino.pointcoordinates (strAttractor)
k=k+1
Next

Dim i, j, l, v
For i=0 To intXMax
For j=0 To intYmax
Rhino.EnableRedraw (False)
If i Mod 2 = 0 Then
l=j+.57735
Else
l=j
End If
Dim arrAttractor
Dim dblDistance  : dblDistance  = d
v=20/dblDistance
Dim arrCenter    : arrCenter    = Array(i,l,0)
For Each arrAttractor In arrAttractors
Dim testDistance : testDistance = Rhino.distance (arrCenter, arrAttractor)
If testDistance < dblDistance Then
dblDistance = testDistance
End If
Next
Call Rhino.AddPoint (array(i,l,0))
Dim arrPoint1    : arrPoint1    = Array(i-.015*dblDistance*v,l+.025980762113533729*dblDistance*v,0)
Dim arrPoint2    : arrPoint2    = Array(i+.015*dblDistance*v,l+.025980762113533729*dblDistance*v,0)
Dim arrPoint3    : arrPoint3    = Array(i+.03*dblDistance*v,l,0)
Dim arrPoint4    : arrPoint4    = Array(i+.015*dblDistance*v,l-.025980762113533729*dblDistance*v,0)
Dim arrPoint5    : arrPoint5    = Array(i-.015*dblDistance*v,l-.025980762113533729*dblDistance*v,0)
Dim arrPoint6    : arrPoint6    = Array(i-.03*dblDistance*v,l,0)
Dim arrPoint1a    : arrPoint1a    = Array(i-.015*dblDistance*v,l+.025980762113533729*dblDistance*v,1)
Dim arrPoint2a    : arrPoint2a    = Array(i+.015*dblDistance*v,l+.025980762113533729*dblDistance*v,1)
Dim arrPoint3a    : arrPoint3a    = Array(i+.03*dblDistance*v,l,1)
Dim arrPoint4a    : arrPoint4a    = Array(i+.015*dblDistance*v,l-.025980762113533729*dblDistance*v,1)
Dim arrPoint5a    : arrPoint5a    = Array(i-.015*dblDistance*v,l-.025980762113533729*dblDistance*v,1)
Dim arrPoint6a    : arrPoint6a    = Array(i-.03*dblDistance*v,l,1)
Dim arrPoint7     : arrPoint7    = Array(i,l,v*dblDistance*.2)
ReDim arrObject(5)
arrObject(0) = Rhino.AddLine (arrPoint1, arrPoint2)
arrObject(1) = Rhino.AddLine (arrPoint2, arrPoint3)
arrObject(2) = Rhino.AddLine (arrPoint3, arrPoint4)
arrObject(3) = Rhino.AddLine (arrPoint4, arrPoint5)
arrObject(4) = Rhino.AddLine (arrPoint5, arrPoint6)
arrObject(5) = Rhino.AddLine (arrPoint6, arrPoint1)
ReDim arrCanopy(5)
arrCanopy(0) = Rhino.AddCurve (array(arrPoint1, arrPoint1a, arrPoint7))
arrCanopy(1) = Rhino.AddCurve (array(arrPoint2, arrPoint2a, arrPoint7))
arrCanopy(2) = Rhino.AddCurve (array(arrPoint3, arrPoint3a, arrPoint7))
arrCanopy(3) = Rhino.AddCurve (array(arrPoint4, arrPoint4a, arrPoint7))
arrCanopy(4) = Rhino.AddCurve (array(arrPoint5, arrPoint5a, arrPoint7))
arrCanopy(5) = Rhino.AddCurve (array(arrPoint6, arrPoint6a, arrPoint7))
Dim arrLoftSurface : arrLoftSurface = Rhino.AddLoftSrf (Array(arrCanopy(0),arrCanopy(1),arrCanopy(2),arrCanopy(3),arrCanopy(4),arrCanopy(5),arrCanopy(0)),,,3)
Call Rhino.DeleteObjects (arrCanopy)
If IsArray(arrObject) Then
Dim strSrf : strSrf =  Rhino.AddPlanarSrf (arrObject)
Call Rhino.DeleteObjects (arrObject)
End If
Dim lngColor : lngColor = Color -(dblDistance*c)
If lngColor < 0 Then
lngColor = 0
End If
Dim arrColorR : arrColorR = (127-(fix(dblDistance*(127/c))))
Dim arrColorB : arrColorB = (191+(fix(dblDistance*(64/c))))
Call Rhino.objectColor (strSrf, rgb(arrColorR,255,arrColorB))
Call Rhino.objectColor (arrLoftSurface, rgb(arrColorR,255,arrColorB))
j=j+.1547
Next
Next
Rhino.DeleteObjects (arrStrAttractors)
rhino.EnableRedraw (True)
End Sub

070924_M.Bearak_Sin

071006_mm.jpg 

Dim i
Dim IntUpper : IntUpper = 100
Dim arrMajorPoint()
Dim arrMinorPoint()
For i = 0 To IntUpper
ReDim Preserve arrMajorPoint(IntUpper)
ReDim Preserve arrMinorPoint(IntUpper)
arrMajorPoint(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(i,0,0)))
arrMinorPoint(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(i, sin(i), cos(i))))
If (Rhino.Distance(arrMajorPoint(i),arrMinorPoint(i)))<= 1.75 Then
Call Rhino.AddLine(arrMajorPoint(i),arrMinorPoint(i))
End If
Next
Call Rhino.AddCurve (arrMajorPoint)
Call Rhino.AddCylinder (arrMajorPoint(0), arrMajorpoint(IntUpper),.5)
Call Rhino.AddInterpCurve (arrMinorPoint)

070926_M.Bearak_MainStructureGeneration

robot :: perception

Man + Machine + well, another machine…

robotperception.jpg

Option Explicit
‘Script written by <mark bearak>
‘Script copyrighted by <dtls.architecture>
‘Script version Monday, September 24, 2007 11:41:45 AM

Call Main()

Sub Main()
Dim k,l
Dim u,v
Dim arrPoint
Dim arrContextPts()

Dim arrSrf : arrSrf = Rhino.GetObject (”Select a host surf”)

Dim intU : intU = 100
Dim intV : intV = 20

Dim UDomain : UDomain = Rhino.SurfaceDomain(arrSrf, 0)
Dim VDomain : VDomain = Rhino.SurfaceDomain(arrSrf, 1)

Dim UStep : UStep = (UDomain(1) – UDomain(0)) / intU
Dim VStep : VStep = (VDomain(1) – VDomain(0)) / intV

ReDim arrFrame(intU,intV)
ReDim arrPts(intU,intV)

Dim strPoly, strCrv, strCrv2, arrPtNormal
Dim m : m = 0
For k = 0 To intU-1
For l = 0 To intV
ReDim Preserve arrContextPts(m)
u = UDomain(0) + UStep * k
v = VDomain(0) + vStep * l
arrFrame(k,l) = Rhino.SurfaceFrame (arrSrf, array(U,V))
arrContextPts(m) = Rhino.AddPoints (array(arrFrame(k,l)(0)))
m = m+1
Next
Next

Dim i, j
Dim IntUpper : IntUpper = 100
Dim n: n=0
Dim arrMajorPointa()
Dim arrMajorPointb()
Dim arrMajorPointc()
Dim arrCenterPoint()
Dim arrMajorCross()
Dim arrMinorPointa(),arrMinorPointb(),arrMinorPointc(),arrMinorPointd()
Dim strLine
Dim strIntLinea(), strIntLineb(), strIntLinec(), strIntLined()
Dim strMajorLine()
Dim strPt
Dim arrpt
For i = 0 To IntUpper
ReDim Preserve arrMajorPointa(IntUpper)
ReDim Preserve arrMajorPointb(IntUpper)
ReDim Preserve arrMajorPointc(IntUpper)
ReDim Preserve arrCenterPoint(IntUpper)
ReDim Preserve arrMajorCross(IntUpper)
ReDim Preserve arrMinorPointa(IntUpper)
ReDim Preserve arrMinorPointb(IntUpper)
ReDim Preserve arrMinorPointc(IntUpper)
ReDim Preserve arrMinorPointd(IntUpper)
Dim dblSin : dblSin = (Sin(i/4)*3)
arrMajorPointa(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(i,dblSin+(sin(i))/4,(sin(i))/4+1)))
arrMajorPointb(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(i,dblSin+(sin(i))/4+.5,0)))
arrMajorPointc(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(i,dblSin+(((sin(i))/4)*-1)-.5,0)))
arrMajorCross(i) = Rhino.AddInterpCurve (array(arrMajorPointa(i),arrMajorPointb(i),arrMajorPointc(i),arrMajorPointa(i)))
strPt = Rhino.CurveAreaCentroid(arrMajorCross(i))
arrPt = Rhino.PointCoordinates(Rhino.AddPoint(strPt(0)))
arrMinorPointa(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(arrPt(0), arrPt(1) + (sin(i)*-1), arrPt(2) + (cos(i)*2))))
arrMinorPointb(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(arrPt(0), arrPt(1) + (sin(i)*-1), arrPt(2) + (cos(i)*-2))))
arrMinorPointc(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(arrPt(0), arrPt(1) + sin(i), arrPt(2) + (cos(i)*-2))))
arrMinorPointd(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(arrPt(0), arrPt(1) + sin(i), arrPt(2) + (cos(i)*2))))
If (Rhino.Distance(arrPt,arrMinorPointa(i)))<= 1.75 Then
ReDim Preserve strIntLinea(n), strIntLineb(n), strIntLinec(n), strIntLined(n)
ReDim Preserve strMajorLine(n)
strIntLinea(n) = Rhino.AddLine (arrPt,arrMinorPointa(i))
strIntLineb(n) = Rhino.AddLine (arrPt,arrMinorPointb(i))
strIntLinec(n) = Rhino.AddLine (arrPt,arrMinorPointc(i))
strIntLined(n) = Rhino.AddLine (arrPt,arrMinorPointd(i))
strMajorLine(n) = arrMajorCross(i)
n= n+1
‘Dim arrNearest : arrNearest = NearestNeighbor (arrContextPts,arrMinorPointa(i))
‘Call Rhino.Print(arrNearest)
‘Call Rhino.AddLine (arrMinorPointa(i),arrNearest)
End If

Next
Rhino.AddLoftSrf (arrMajorCross)
Call Rhino.AddInterpCurve (arrMajorPointa)
Call Rhino.AddInterpCurve (arrMajorPointb)
Call Rhino.AddInterpCurve (arrMajorPointc)
Call Rhino.AddInterpCurve (arrMinorPointa)
Call Rhino.AddInterpCurve (arrMinorPointb)
Call Rhino.AddInterpCurve (arrMinorPointc)
Call Rhino.AddInterpCurve (arrMinorPointd)
Rhino.Command (”selsrf “)
Dim arrSurface: arrSurface =Rhino.GetObject(, , vbTrue)
For j = 0 To UBound(strIntLinea)
Dim arrIntPta: arrIntPta = CCX(strIntLinea(j), strMajorLine(j))
Call Rhino.AddPoint (arrIntPta)
Dim strCrsLinea : strCrsLinea = Rhino.AddLine (arrIntPta, Rhino.CurveEndPoint(strIntLinea(j)))
Call Rhino.DeleteObject (strIntLinea(j))
Call Rhino.AddCylinder (Rhino.CurveStartPoint(strCrsLinea), Rhino.CurveEndPoint(strCrsLinea),(Rhino.Distance(Rhino.CurveStartPoint(strCrsLinea), Rhino.CurveEndPoint(strCrsLinea)))/30)
Next
For j = 0 To UBound(strIntLineb)
Dim arrIntPtb: arrIntPtb = CCX(strIntLineb(j), strMajorLine(j))
Call Rhino.AddPoint (arrIntPtb)
Dim strCrsLineb : strCrsLineb = Rhino.AddLine (arrIntPtb, Rhino.CurveEndPoint(strIntLineb(j)))
Call Rhino.DeleteObject (strIntLineb(j))
Call Rhino.AddCylinder (Rhino.CurveStartPoint(strCrsLineb), Rhino.CurveEndPoint(strCrsLineb),(Rhino.Distance(Rhino.CurveStartPoint(strCrsLineb), Rhino.CurveEndPoint(strCrsLineb)))/30)
Next
For j = 0 To UBound(strIntLinec)
Dim arrIntPtc: arrIntPtc = CCX(strIntLinec(j), strMajorLine(j))
Call Rhino.AddPoint (arrIntPtc)
Dim strCrsLinec : strCrsLinec = Rhino.AddLine (arrIntPtc, Rhino.CurveEndPoint(strIntLinec(j)))
Call Rhino.DeleteObject (strIntLinec(j))
Call Rhino.AddCylinder (Rhino.CurveStartPoint(strCrsLinec), Rhino.CurveEndPoint(strCrsLinec),(Rhino.Distance(Rhino.CurveStartPoint(strCrsLinec), Rhino.CurveEndPoint(strCrsLinec)))/30)
Next
For j = 0 To UBound(strIntLined)
Dim arrIntPtd: arrIntPtd = CCX(strIntLined(j), strMajorLine(j))
Call Rhino.AddPoint (arrIntPtd)
Dim strCrsLined : strCrsLined = Rhino.AddLine (arrIntPtd, Rhino.CurveEndPoint(strIntLined(j)))
Call Rhino.DeleteObject (strIntLined(j))
Call Rhino.AddCylinder (Rhino.CurveStartPoint(strCrsLined), Rhino.CurveEndPoint(strCrsLined),(Rhino.Distance(Rhino.CurveStartPoint(strCrsLined), Rhino.CurveEndPoint(strCrsLined)))/30)
Next
End Sub

Function CCX(strCurve, strSurface)
Dim arrCCX
If IsNull(strCurve) Or Rhino.IsCurve(strCurve) = False Then Exit Function
If IsNull(strSurface) Or Rhino.IsCurve(strSurface) = False Then Exit Function
arrCCX = Rhino.CurveCurveIntersection(strCurve, strSurface)
If Not IsArray(arrCCX) Then
Rhino.Print “Curve and curve do not intersect.”
Exit Function
End If
Dim i
For i = 0 To UBound(arrCCX)
If arrCCX(i,0) = 1 Then
Rhino.Print “Intersection point on curve: ” & Rhino.Pt2Str(arrCCX(i,1))
CCX = arrCCX(i,1)
End If
Next
End Function

Function NearestNeighbor(arrPts,index)
Dim n, dblDist
Dim dblDistMin : dblDistMin = 1000000
For n = 0 To UBound(arrPts)
dblDist = Rhino.Distance (index,arrPts(n))
If dblDist <> 0 And dblDist < dblDistMin Then
dblDistMin = dblDist
Dim arrPtNear : arrPtNear = arrPts(n)
End If
Next
NearestNeighbor = arrPtNear
End Function

 

071016_M.Bearak_CoreGenerator

sstower-growth16.jpg

Option Explicit
‘Script written by mark bearak
‘Script copyrighted by dtls.architecture
‘Script version Monday, October 08, 2007 3:01:43 PM

Call Main()
Sub Main()
Call Rhino.EnableRedraw (False)
Dim arrPt, arrPoint()
Dim n : n = 0
Dim i, IntUpper : IntUpper = 125
Dim arrMajorPointa()
Dim arrMajorPointb()
Dim arrMajorPointc()
Dim arrMajorCross()
Dim strObject : strObject = Rhino.GetObject (“Pick your line to snort”, 4)
Dim arrPts: arrPts = Rhino.DivideCurve (strObject, IntUpper)
For Each arrPt In arrPts
ReDim Preserve arrPoint(n)
arrPoint(n) = Rhino.AddPoint (arrPt)
n=n+1
Next
For i = 0 To IntUpper
ReDim Preserve arrMajorPointa(IntUpper)
ReDim Preserve arrMajorPointb(IntUpper)
ReDim Preserve arrMajorPointc(IntUpper)
ReDim Preserve arrMajorCross(IntUpper)
Dim arrCntPt : arrCntPt = Rhino.PointCoordinates (arrPoint(i))
arrMajorPointa(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(arrCntPt(0)+((sin(i/8))/2)*10,arrCntPt(1)+((sin(i/8))/4+1)*10,arrCntPt(2))))
arrMajorPointb(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(arrCntPt(0)+(((sin(i/8))/2)+.5)*10,arrCntPt(1),arrCntPt(2))))
arrMajorPointc(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(arrCntPt(0)+(((sin(i/8))/-2)-.5)*10,arrCntPt(1),arrCntPt(2))))
arrMajorCross(i) = Rhino.AddInterpCurve (array(arrMajorPointa(i),arrMajorPointb(i),arrMajorPointc(i),arrMajorPointa(i)))
Next
Call Rhino.AddLoftSrf (arrMajorCross)
Call Rhino.DeleteObjects (arrMajorCross)
Rhino.Command “Selpt Delete “
Call Rhino.EnableRedraw (True)
End Sub

071005_M.Bearak_Meshing

robot :: perception

Man + Machine + well, another machine…

meshstructure.jpg

Option Explicit
‘Script written by mark bearak
‘Script copyrighted by dtls.architecture
‘Script version Friday, October 05, 2007 10:54:37 AM

Call Main()
Sub Main()

Dim i,j, k
Dim u,v
Dim arrPoint

Dim strSrf : strSrf = Rhino.GetObject (“Select a host surf”,12)
Dim intU : intU = 22 ‘Horizontal
Dim intV : intV = 24 ‘Vertical
Dim UDomain : UDomain = Rhino.SurfaceDomain(strSrf, 0)
Dim VDomain : VDomain = Rhino.SurfaceDomain(strSrf, 1)
Dim UStep : UStep = (UDomain(1) – UDomain(0)) / intU
Dim VStep : VStep = (VDomain(1) – VDomain(0)) / intV
ReDim arrFrame(intU,intV)
ReDim arrPts(intU,intV)

Dim strCrv, strCrvb, arrPlane, arrPtNormal, dblRadius
Dim arrCircle(), arrCircleb()

dblRadius = .3
For i = 0 To intU
For j = 0 To intV
u = UDomain(0) + UStep * i
v = VDomain(0) + vStep * j
arrFrame(i,j) = Rhino.SurfaceFrame (strSrf, array(U,V))
Call Rhino.AddPoints (array(arrFrame(i,j)(0)))
If (i > 1)And (i Mod 2 = 0) And (j>23) Then
k = ((intU+1) – i)/40
ReDim Preserve arrCircle(12)
ReDim Preserve arrCircleb(12)
arrPtNormal = Rhino.PointAdd(arrFrame(i,j)(0), Rhino.VectorScale (arrFrame(i,j)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i,j)(0), arrFrame(i-1,j)(0), arrPtNormal)
arrCircle(0) =  Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-2)(0), Rhino.VectorScale (arrFrame(i-1,j-2)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-2)(0), arrFrame(i-2,j-2)(0), arrPtNormal)
arrCircle(1) =  Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i,j-4)(0), Rhino.VectorScale (arrFrame(i,j-4)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i,j-4)(0), arrFrame(i-1,j-4)(0), arrPtNormal)
arrCircle(2) =   Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-6)(0), Rhino.VectorScale (arrFrame(i-1,j-6)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-6)(0), arrFrame(i-2,j-6)(0), arrPtNormal)
arrCircle(3) =   Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i,j-8)(0), Rhino.VectorScale (arrFrame(i,j-8)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i,j-8)(0), arrFrame(i-1,j-8)(0), arrPtNormal)
arrCircle(4) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-10)(0), Rhino.VectorScale (arrFrame(i-1,j-10)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-10)(0), arrFrame(i-2,j-10)(0), arrPtNormal)
arrCircle(5) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i,j-12)(0), Rhino.VectorScale (arrFrame(i,j-12)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i,j-12)(0), arrFrame(i-1,j-12)(0), arrPtNormal)
arrCircle(6) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-14)(0), Rhino.VectorScale (arrFrame(i-1,j-14)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-14)(0), arrFrame(i-2,j-14)(0), arrPtNormal)
arrCircle(7) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i,j-16)(0), Rhino.VectorScale (arrFrame(i,j-16)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i,j-16)(0), arrFrame(i-1,j-16)(0), arrPtNormal)
arrCircle(8) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-18)(0), Rhino.VectorScale (arrFrame(i-1,j-18)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-18)(0), arrFrame(i-2,j-18)(0), arrPtNormal)
arrCircle(9) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i,j-20)(0), Rhino.VectorScale (arrFrame(i,j-20)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i,j-20)(0), arrFrame(i-1,j-20)(0), arrPtNormal)
arrCircle(10) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-22)(0), Rhino.VectorScale (arrFrame(i-1,j-22)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-22)(0), arrFrame(i-2,j-22)(0), arrPtNormal)
arrCircle(11) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i,j-24)(0), Rhino.VectorScale (arrFrame(i,j-24)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i,j-24)(0), arrFrame(i-1,j-24)(0), arrPtNormal)
arrCircle(12) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-2,j)(0), Rhino.VectorScale (arrFrame(i-2,j)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-2,j)(0), arrFrame(i-1,j)(0), arrPtNormal)
arrCircleb(0) =  Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-2)(0), Rhino.VectorScale (arrFrame(i-1,j-2)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-2)(0), arrFrame(i,j-2)(0), arrPtNormal)
arrCircleb(1) =  Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-2,j-4)(0), Rhino.VectorScale (arrFrame(i-2,j-4)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-2,j-4)(0), arrFrame(i-1,j-4)(0), arrPtNormal)
arrCircleb(2) =   Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-6)(0), Rhino.VectorScale (arrFrame(i-1,j-6)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-6)(0), arrFrame(i,j-6)(0), arrPtNormal)
arrCircleb(3) =   Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-2,j-8)(0), Rhino.VectorScale (arrFrame(i-2,j-8)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-2,j-8)(0), arrFrame(i-1,j-8)(0), arrPtNormal)
arrCircleb(4) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-10)(0), Rhino.VectorScale (arrFrame(i-1,j-10)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-10)(0), arrFrame(i,j-10)(0), arrPtNormal)
arrCircleb(5) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-2,j-12)(0), Rhino.VectorScale (arrFrame(i-2,j-12)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-2,j-12)(0), arrFrame(i-1,j-12)(0), arrPtNormal)
arrCircleb(6) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-14)(0), Rhino.VectorScale (arrFrame(i-1,j-14)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-14)(0), arrFrame(i,j-14)(0), arrPtNormal)
arrCircleb(7) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-2,j-16)(0), Rhino.VectorScale (arrFrame(i-2,j-16)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-2,j-16)(0), arrFrame(i-1,j-16)(0), arrPtNormal)
arrCircleb(8) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-18)(0), Rhino.VectorScale (arrFrame(i-1,j-18)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-18)(0), arrFrame(i,j-18)(0), arrPtNormal)
arrCircleb(9) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-2,j-20)(0), Rhino.VectorScale (arrFrame(i-2,j-20)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-2,j-20)(0), arrFrame(i-1,j-20)(0), arrPtNormal)
arrCircleb(10) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-1,j-22)(0), Rhino.VectorScale (arrFrame(i-1,j-22)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-1,j-22)(0), arrFrame(i,j-22)(0), arrPtNormal)
arrCircleb(11) = Rhino.AddCircle (arrPlane, dblRadius+k)

arrPtNormal = Rhino.PointAdd(arrFrame(i-2,j-24)(0), Rhino.VectorScale (arrFrame(i-2,j-24)(3),UStep))
arrPlane = Rhino.PlaneFromPoints (arrFrame(i-2,j-24)(0), arrFrame(i-1,j-24)(0), arrPtNormal)
arrCircleb(12) = Rhino.AddCircle (arrPlane, dblRadius+k)

Call Rhino.AddLoftSrf (arrCircle)
Call Rhino.AddLoftSrf (arrCircleb)

‘strcrvb = rhino.AddInterpCurve (array(arrFrame(i-2,j)(0),_
‘    arrFrame(i-1,j-2)(0),_
‘    arrFrame(i-2,j-4)(0),_
‘    arrFrame(i-1,j-6)(0),_
‘    arrFrame(i-2,j-8)(0),_
‘    arrFrame(i-1,j-10)(0),_
‘    arrFrame(i-2,j-14)(0),_
‘    arrFrame(i-1,j-16)(0),_
‘    arrFrame(i-2,j-18)(0),_
‘    arrFrame(i-1,j-20)(0),_
‘    arrFrame(i-2,j-22)(0)))
End If
Next
Next
End Sub

071016_M.Bearak_RandomGrowth

sstower-growth12.jpgOption Explicit
‘Script written by mark bearak
‘Script copyrighted by dtls.architecture
‘Script version Wednesday, October 03, 2007 12:27:33 PM

Call Main()
Sub Main()
Dim i, IntUpper : IntUpper = 100
Dim arrMajorPointa()
Dim arrMajorPointb()
Dim arrMajorPointc()
Dim arrMajorCross()
For i = 0 To IntUpper
ReDim Preserve arrMajorPointa(IntUpper)
ReDim Preserve arrMajorPointb(IntUpper)
ReDim Preserve arrMajorPointc(IntUpper)
ReDim Preserve arrMajorCross(IntUpper)
Dim dblSin : dblSin = (Sin(i/12)*3)
arrMajorPointa(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(dblSin+(sin(i/6))/2,(sin(i/8))/4+1,i)))
arrMajorPointb(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(dblSin+(sin(i/6))/2+.5,0,i)))
arrMajorPointc(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(dblSin+(((sin(i/6))/2)*-1)-.5,0,i)))
arrMajorCross(i) = Rhino.AddInterpCurve (array(arrMajorPointa(i),arrMajorPointb(i),arrMajorPointc(i),arrMajorPointa(i)))
Next
Call Rhino.AddLoftSrf (arrMajorCross)
End Sub

071023_MBearak_Generated Environment

meshingenvironment.jpg

Option Explicit
‘Script written by mark bearak
‘Script copyrighted by dtls.architecture
‘Script version Monday, October 22, 2007 3:16:51 PM

Call Main()
Sub Main()
Dim h, i
Dim dblRadius, intFreq, dblConv, strPt, arrPts(), arrSrf()
Dim dblCntX, dblCntY, dblCntZ
dblConv = 0.0174532925
For h = 0 To 20
If h <11 Then
intFreq = h*10
dblRadius = 40 + h*2
Else
intFreq = 200 – (h*10)
dblRadius = 40 + (40 – h*2)
End If
ReDim Preserve arrSrf(h)
For i = 0 To 36
DblCntX = 0
DblCntY = 0
DblCntZ = h*10

ReDim Preserve arrPts(i)
strPt = Rhino.AddPoint (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+.333)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+.333)+DblCntY, 0+DblCntZ))
arrPts(i) = Rhino.PointCoordinates (strPt)
Call Rhino.DeleteObject (strPt)
Next
arrSrf(h) = Rhino.AddInterpCurve (arrPts)
Next
‘Call Rhino.AddLoftSrf (arrSrf)
‘Call Rhino.DeleteObjects (arrSrf)
End Sub

071023_MBearak_Interlocking Linear Mesh

meshing.jpg

Option Explicit
‘Script written by mark bearak
‘Script copyrighted by dtls.architecture
‘Script version Wednesday, October 17, 2007 12:19:11 PM

Call Main()
Sub Main()
Dim h, i, j, k, l, n, o
Dim arrStart, arrPoint, arrPlane, dblLength
Dim dblIniLength : dblIniLength = 16
Dim dblHeight : dblHeight = 3
Dim ArrPta(), ArrPtb(), ArrPtc(), ArrPtd()
Dim dblRadius : dblRadius = .4
j = 0
For h = 0 To 15
i = h*dblRadius*8
For k = 0 To 12
dblLength = dblIniLength * 2
ReDim Preserve ArrPta(k), ArrPtb(k)
If (k Mod 2 = 0) Then
arrPlane = Rhino.PlaneFromPoints (Array(k*dblLength,j+dblRadius+i,0), Array(k*dblLength,j+i,0), Array(k*dblLength,j+.5+i,1))
arrPta(k) = Rhino.AddCircle (arrPlane, dblRadius)
arrPlane = Rhino.PlaneFromPoints (Array(k*dblLength,j-dblRadius+i,0), Array(k*dblLength,j+i,0), Array(k*dblLength,j-.5+i,1))
arrPtb(k) = Rhino.AddCircle (arrPlane, dblRadius)
Else
arrPlane = Rhino.PlaneFromPoints (Array(k*dblLength,j+dblRadius+i,dblHeight),Array(k*dblLength,j+i,dblHeight), Array(k*dblLength,j+.5+i,dblHeight+1))
arrPta(k) = Rhino.AddCircle (arrPlane, dblRadius)
arrPlane = Rhino.PlaneFromPoints (Array(k*dblLength,j-dblRadius+i,dblHeight),Array(k*dblLength,j+i,dblHeight), Array(k*dblLength,j-.5+i,dblHeight+1))
arrPtb(k) = Rhino.AddCircle (arrPlane, dblRadius)
End If
Next
For l = 0 To 24
dblLength = dblIniLength
ReDim Preserve  ArrPtc(l), ArrPtd(l)
If (l Mod 4 = 0) Then
arrPlane = Rhino.PlaneFromPoints (Array(l*dblLength,j+i,dblHeight/2-dblRadius), Array(l*dblLength,j+1+i,dblHeight/2-dblRadius), Array(l*dblLength,j+i,dblHeight))
arrPtc(l) = Rhino.AddCircle (arrPlane, dblRadius)
arrPlane = Rhino.PlaneFromPoints (Array(l*dblLength,j+i,dblHeight/2+dblRadius), Array(l*dblLength,j+1+i,dblHeight/2+dblRadius), Array(l*dblLength,j+i,dblHeight))
arrPtd(l) = Rhino.AddCircle (arrPlane, dblRadius)
Else
If (l Mod 4 = 2) Then
arrPlane = Rhino.PlaneFromPoints (Array(l*dblLength,j+i,dblHeight/2+dblRadius), Array(l*dblLength,j+1+i,dblHeight/2+dblRadius), Array(l*dblLength,j+i,dblHeight))
arrPtc(l) = Rhino.AddCircle (arrPlane, dblRadius)
arrPlane = Rhino.PlaneFromPoints (Array(l*dblLength,j+i,dblHeight/2-dblRadius), Array(l*dblLength,j+1+i,dblHeight/2-dblRadius), Array(l*dblLength,j+i,dblHeight))
arrPtd(l) = Rhino.AddCircle (arrPlane, dblRadius)
Else
If (l Mod 4 = 1) Then
arrPlane = Rhino.PlaneFromPoints (Array(l*dblLength,j-(dblRadius*(dblRadius*12))+i,dblHeight/2), Array(l*dblLength,j+3+i,dblHeight/2-dblRadius), Array(l*dblLength,j-1.5+i,dblHeight))
arrPtc(l) = Rhino.AddCircle (arrPlane, dblRadius)
arrPlane = Rhino.PlaneFromPoints (Array(l*dblLength,j+(dblRadius*(dblRadius*12))+i,dblHeight/2), Array(l*dblLength,j+3+i,dblHeight/2+dblRadius), Array(l*dblLength,j+1.5+i,dblHeight))
arrPtd(l) = Rhino.AddCircle (arrPlane, dblRadius)
Else
arrPlane = Rhino.PlaneFromPoints (Array(l*dblLength,j+(dblRadius*(dblRadius*12))+i,dblHeight/2), Array(l*dblLength,j+3+i,dblHeight/2-dblRadius), Array(l*dblLength,j+1.5+i,dblHeight))
arrPtc(l) = Rhino.AddCircle (arrPlane, dblRadius)
arrPlane = Rhino.PlaneFromPoints (Array(l*dblLength,j-(dblRadius*(dblRadius*12))+i,dblHeight/2), Array(l*dblLength,j+3+i,dblHeight/2+dblRadius), Array(l*dblLength,j-1.5,dblHeight))
arrPtd(l) = Rhino.AddCircle (arrPlane, dblRadius)
End If
End If
End If
Next
Call Rhino.AddLoftSrf (arrPta)
Call Rhino.DeleteObjects (arrPta)
Call Rhino.AddLoftSrf (arrPtb)
Call Rhino.DeleteObjects (arrPtb)
Call Rhino.AddLoftSrf (arrPtc)
Call Rhino.DeleteObjects (arrPtc)
Call Rhino.AddLoftSrf (arrPtd)
Call Rhino.DeleteObjects (arrPtd)
Next

End Sub

 

071018_M.Bearak_Meshing Test

Option Explicit
‘Script written by mark bearak
‘Script copyrighted by dtls.architecture
‘Script version Wednesday, October 17, 2007 12:19:11 PM

Call Main()
Sub Main()
Dim j, k, l, n
Dim arrStart, arrPoint, arrPlane
Dim dblLength : dblLength = 16
Dim dblHeight : dblHeight = 3
Dim Arrpta(), Arrptb(), Arrptc(), Arrptd()
Dim dblRadius : dblRadius = .2
j = 0
For k = 0 To 12
ReDim Preserve ArrPta(k), ArrPtb(k), ArrPtc(k), ArrPtd(k)
l = j
If (k Mod 2 = 0) Then
arrPlane = Rhino.PlaneFromPoints (Array(k*dblLength,l+.5,0), Array(k*dblLength,l,0), Array(k*dblLength,l+.5,1))
arrPta(k) = Rhino.AddCircle (arrPlane, dblRadius)
arrPlane = Rhino.PlaneFromPoints (Array(k*dblLength,l-.5,0), Array(k*dblLength,l,0), Array(k*dblLength,l-.5,1))
arrPtb(k) = Rhino.AddCircle (arrPlane, dblRadius)
Else
arrPlane = Rhino.PlaneFromPoints (Array(k*dblLength,l+.5,dblHeight),Array(k*dblLength,l,dblHeight), Array(k*dblLength,l+.5,dblHeight+1))
arrPta(k) = Rhino.AddCircle (arrPlane, dblRadius)
arrPlane = Rhino.PlaneFromPoints (Array(k*dblLength,l-.5,dblHeight),Array(k*dblLength,l,dblHeight), Array(k*dblLength,l-.5,dblHeight+1))
arrPtb(k) = Rhino.AddCircle (arrPlane, dblRadius)
End If
If (k Mod 2 = 1) Then
arrPlane = Rhino.PlaneFromPoints (Array(k*dblLength,l,dblHeight/2-.25), Array(k*dblLength,l+1,dblHeight/2-.25), Array(k*dblLength,l,dblHeight))
arrPtc(k) = Rhino.AddCircle (arrPlane, dblRadius)
arrPlane = Rhino.PlaneFromPoints (Array(k*dblLength,l,dblHeight/2+.25), Array(k*dblLength,l+1,dblHeight/2+.25), Array(k*dblLength,l,dblHeight))
arrPtd(k) = Rhino.AddCircle (arrPlane, dblRadius)
Else
If (k Mod 4 = 0) Then
arrPlane = Rhino.PlaneFromPoints (Array(k*dblLength,l-1.5,dblHeight/2-.25), Array(k*dblLength,l+3,dblHeight/2-.25), Array(k*dblLength,l-1.5,dblHeight))
arrPtc(k) = Rhino.AddCircle (arrPlane, dblRadius)
arrPlane = Rhino.PlaneFromPoints (Array(k*dblLength,l+1.5,dblHeight/2+.25), Array(k*dblLength,l+3,dblHeight/2+.25), Array(k*dblLength,l+1.5,dblHeight))
arrPtd(k) = Rhino.AddCircle (arrPlane, dblRadius)
Else
arrPlane = Rhino.PlaneFromPoints (Array(k*dblLength,l+1.5,dblHeight/2-.25), Array(k*dblLength,l+3,dblHeight/2-.25), Array(k*dblLength,l+1.5,dblHeight))
arrPtc(k) = Rhino.AddCircle (arrPlane, dblRadius)
arrPlane = Rhino.PlaneFromPoints (Array(k*dblLength,l-1.5,dblHeight/2+.25), Array(k*dblLength,l+3,dblHeight/2+.25), Array(k*dblLength,l-1.5,dblHeight))
arrPtd(k) = Rhino.AddCircle (arrPlane, dblRadius)
End If
End If
Next
Call Rhino.AddLoftSrf (arrPta)
Call Rhino.DeleteObjects (arrPta)
Call Rhino.AddLoftSrf (arrPtb)
Call Rhino.DeleteObjects (arrPtb)
Call Rhino.AddLoftSrf (arrPtc)
Call Rhino.DeleteObjects (arrPtc)
Call Rhino.AddLoftSrf (arrPtd)
Call Rhino.DeleteObjects (arrPtd)
End Sub

 

071024_MBearak_Weaving Bowl

meshingbowl1.jpg

meshingbowl2.jpg

Option Explicit
‘Script written by mark.bearak
‘Script copyrighted by dtls.architecture
‘Script version Monday, October 22, 2007 3:16:51 PM

Call Main()
Sub Main()
Dim h, i
Dim dblRadius, vecDir, intFreq, dblConv, n, dblInflect, arrMovPta(), arrMovPtb(), arrMovPtc(), arrMovPtd(), arrMovPte(), blnEven
Dim dblRad : dblRad = 1
Dim dblSpread : dblSpread = 6
Dim dblCntX, dblCntY, dblCntZ
dblConv = 0.0174532925
For h = 0 To 20
If (h Mod 2=1) Then
n = 0
intFreq = 0
ReDim Preserve arrSrf(h)
For i = 0 To 36
ReDim Preserve arrMovPtd(i)
ReDim Preserve arrMovPte(i)
If (i Mod 4 = 0)Then
blnEven = 1
Else
blnEven = -1
End If
DblCntX = 0
DblCntY = 0
DblCntZ = h*7

If (i Mod 2 = 0) Then
dblRadius = 20+h
dblInflect = dblRadius/10
ReDim Preserve arrMovPta(n)
ReDim Preserve arrMovPtb(n)
ReDim Preserve arrMovPtc(n)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ-(dblRad*(dblSpread/2))),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ-(dblRad*(dblSpread/2))))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, 90*blnEven, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread)
arrMovPta(n) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ-(dblRad*(dblSpread/2))),vecDir)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, -90*blnEven, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread)
arrMovPtb(n) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ+(dblRad*(dblSpread/2))),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ+(dblRad*(dblSpread/2))))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, 90*blnEven, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread)
arrMovPtc(n) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ+(dblRad*(dblSpread/2))),vecDir)
n = n + 1
End If

If (i Mod 4 = 0) Then
dblRadius = 20+h
dblInflect = dblRadius/10
vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, 90, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread/3)
arrMovPtd(i) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, -90, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread/3)
arrMovPte(i) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)
Else
If (i Mod 4 = 1) Then
dblRadius = 20+h+1
dblInflect = dblRadius/10
arrMovPtd(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ+(dblRad*dblSpread*1.5))))
dblRadius = 20+h-1
dblInflect = dblRadius/10
arrMovPte(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ-(dblRad*dblSpread*1.5))))
Else
If (i Mod 4 = 2) Then
dblRadius = 20+h
dblInflect = dblRadius/10
vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, -90, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread/3)
arrMovPtd(i) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, 90, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread/3)
arrMovPte(i) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)
Else
dblRadius = 20+h-1
dblInflect = dblRadius/10
arrMovPtd(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ-(dblRad*dblSpread*1.5))))
dblRadius = 20+h+1
dblInflect = dblRadius/10
arrMovPte(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ+(dblRad*dblSpread*1.5))))
End If
End If
End If
Next
Call AddPipe(arrMovPta,dblRad)
Call AddPipe(arrMovPtb,dblRad)
Call AddPipe(arrMovPtc,dblRad)
Call AddPipe(arrMovPtd,dblRad)
Call AddPipe(arrMovPte,dblRad)
End If
Next
End Sub

Function AddPipe(arrMovPta,dblRad)
Dim strLine
strLine = Rhino.AddInterpCurve (arrMovPta)
Call Rhino.SelectObject (strLine)
Call Rhino.Command (“Pipe “&dblRad&” “&dblRad&” enter”)
Call Rhino.Command (“Selnone “)
End Function

071030_MBearak_ContextuallyConsciousWeaving

finalweavingscript3.jpg

finalweavingscript4.jpg

finalweavingscript2.jpg

finalweavingscript1.jpg

Option Explicit
‘Script written by mark.bearak
‘Script copyrighted by dtls.architecture
‘Script version Monday, October 22, 2007 3:16:51 PM

Call Main()
Sub Main()
Dim h, i, j, k, n, m, na, nb, nc, nd, ne
Dim dblRadius, dblConv, strPta, strPtb, strPtc, strPtd, strPte, dblRad, arrPtsa(), arrPtsb(), arrPtsc(), arrPtsd(), arrPtse(), arrFinPtsa(), arrFinPtsb(), arrFinPtsc(), arrFinPtsd(), arrFinPtse(), dblTol
Dim stlLinea, stlLineb, stlLinec, stlLined, stlLinee, stlLinePreva, stlLinePrevb, stlLinePrevc, stlLinePrevd, stlLinePreve, dblIntTol
Dim arrCCXab, arrCCXac, arrCCXad, arrCCXae, arrCCXbc, arrCCXbd, arrCCXbe, arrCCXcd, arrCCXce, arrCCXde
Dim arrCCXPab, arrCCXPac, arrCCXPad, arrCCXPae, arrCCXPbc, arrCCXPbd, arrCCXPbe, arrCCXPcd, arrCCXPce, arrCCXPde
Dim strCrva, strCrvb, strCrvc, strCrvd, strCrve

Dim dblAnglea : dblAnglea = 1
Dim dblAngleb : dblAngleb = 1
Dim dblAnglec : dblAnglec = 1
Dim dblAngled : dblAngled = 1
Dim dblAnglee : dblAnglee = 1

dblRad = 1
dblTol = 4
dblIntTol = 1
dblConv = 0.0174532925

For h = 0 To 3
For j = 0 To 20

Dim rnda : rnda = random(0,36)
Dim rndb : rndb = random(0,36)
Dim rndc : rndc = random(0,36)
Dim rndd : rndd = random(0,36)
Dim rnde : rnde = random(0,36)

Dim rndAnglea : rndAnglea = Random(-5,5)*4
Dim rndAngleb : rndAngleb = Random(-5,5)*4
Dim rndAnglec : rndAnglec = Random(-5,5)*4
Dim rndAngled : rndAngled = Random(-5,5)*4
Dim rndAnglee : rndAnglee = Random(-5,5)*4
na=0 : nb=0 : nc=0 : nd=0 : m = 0
For i = 0 To 60
dblRadius = (sin(i/5)*10) + 20
ReDim Preserve arrPtsa(i)
ReDim Preserve arrPtsb(i)
ReDim Preserve arrPtsc(i)
ReDim Preserve arrPtsd(i)
ReDim Preserve arrPtse(i)
ReDim Preserve arrFinPtsa(i)
ReDim Preserve arrFinPtsb(i)
ReDim Preserve arrFinPtsc(i)
ReDim Preserve arrFinPtsd(i)
ReDim Preserve arrFinPtse(i)

strPta = Rhino.AddPoint (array(cos((na+rnda)*rndAnglea*dblConv)*dblRadius, sin((na+rnda)*rndAnglea*dblConv)*dblRadius, i*6))
strPtb = Rhino.AddPoint (array(cos((nb+rndb)*rndAngleb*dblConv)*dblRadius, sin((nb+rndb)*rndAngleb*dblConv)*dblRadius, i*6))
strPtc = Rhino.AddPoint (array(cos((nc+rndc)*rndAnglec*dblConv)*dblRadius, sin((nc+rndc)*rndAnglec*dblConv)*dblRadius, i*6))
strPtd = Rhino.AddPoint (array(cos((nd+rndd)*rndAngled*dblConv)*dblRadius, sin((nd+rndd)*rndAngled*dblConv)*dblRadius, i*6))
strPte = Rhino.AddPoint (array(cos((ne+rnde)*rndAnglee*dblConv)*dblRadius, sin((ne+rnde)*rndAnglee*dblConv)*dblRadius, i*6))
arrPtsa(i) = Rhino.PointCoordinates (strPta)
arrPtsb(i) = Rhino.PointCoordinates (strPtb)
arrPtsc(i) = Rhino.PointCoordinates (strPtc)
arrPtsd(i) = Rhino.PointCoordinates (strPtd)
arrPtse(i) = Rhino.PointCoordinates (strPte)
arrFinPtsa(i) = Rhino.PointCoordinates (strPta)
arrFinPtsb(i) = Rhino.PointCoordinates (strPtb)
arrFinPtsc(i) = Rhino.PointCoordinates (strPtc)
arrFinPtsd(i) = Rhino.PointCoordinates (strPtd)
arrFinPtse(i) = Rhino.PointCoordinates (strPte)
Call Rhino.DeleteObject (strPta):Call Rhino.DeleteObject (strPtb):Call Rhino.DeleteObject (strPtc):Call Rhino.DeleteObject (strPtd):Call Rhino.DeleteObject (strPte)

If i>=2 Then

stlLinea = Rhino.AddInterpCurve (array(arrPtsa(i),arrPtsa(i-1)))
stlLineb = Rhino.AddInterpCurve (array(arrPtsb(i),arrPtsb(i-1)))
stlLinec = Rhino.AddInterpCurve (array(arrPtsc(i),arrPtsc(i-1)))
stlLined = Rhino.AddInterpCurve (array(arrPtsd(i),arrPtsd(i-1)))
stlLinee = Rhino.AddInterpCurve (array(arrPtse(i),arrPtse(i-1)))
stlLinePreva = Rhino.AddInterpCurve (array(arrPtsa(i-1),arrPtsa(i-2)))
stlLinePrevb = Rhino.AddInterpCurve (array(arrPtsb(i-1),arrPtsb(i-2)))
stlLinePrevc = Rhino.AddInterpCurve (array(arrPtsc(i-1),arrPtsc(i-2)))
stlLinePrevd = Rhino.AddInterpCurve (array(arrPtsd(i-1),arrPtsd(i-2)))
stlLinePreve = Rhino.AddInterpCurve (array(arrPtse(i-1),arrPtse(i-2)))

arrCCXab = Rhino.CurveCurveIntersection (stlLinea, stlLineb,dblIntTol)
arrCCXPab = Rhino.CurveCurveIntersection (stlLinePreva, stlLinePrevb,dblIntTol)
If IsArray(arrCCXab) And Not isArray (arrCCXPab) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXab(n,1)), rgb(0,0,255))
dblAnglea = dblAnglea * -1
dblAngleb = dblAngleb * -1
arrFinPtsa(i) = arrCCXab(n,1)
arrFinPtsb(i) = arrCCXab(n,1)
m = m + 1
End If

arrCCXac = Rhino.CurveCurveIntersection (stlLinea, stlLinec,dblIntTol)
arrCCXPac = Rhino.CurveCurveIntersection (stlLinePreva, stlLinePrevc,dblIntTol)
If IsArray(arrCCXac) And Not isArray (arrCCXPac) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXac(n,1)), rgb(0,0,255))
dblAnglea = dblAnglea * -1
dblAnglec = dblAnglec * -1
arrFinPtsa(i) = arrCCXac(n,1)
arrFinPtsc(i) = arrCCXac(n,1)
m = m + 1
End If

arrCCXad = Rhino.CurveCurveIntersection (stlLinea, stlLined,dblIntTol)
arrCCXPad = Rhino.CurveCurveIntersection (stlLinePreva, stlLinePrevd,dblIntTol)
If IsArray(arrCCXad) And Not isArray (arrCCXPad) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXad(n,1)), rgb(0,0,255))
dblAnglea = dblAnglea * -1
dblAngled = dblAngled * -1
arrFinPtsa(i) = arrCCXad(n,1)
arrFinPtsd(i) = arrCCXad(n,1)
m = m + 1
End If

arrCCXae = Rhino.CurveCurveIntersection (stlLinea, stlLinee,dblIntTol)
arrCCXPae = Rhino.CurveCurveIntersection (stlLinePreva, stlLinePreve,dblIntTol)
If IsArray(arrCCXae) And Not isArray (arrCCXPae) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXae(n,1)), rgb(0,0,255))
dblAnglea = dblAnglea * -1
dblAnglee = dblAnglee * -1
arrFinPtsa(i) = arrCCXae(n,1)
arrFinPtse(i) = arrCCXae(n,1)
m = m + 1
End If

arrCCXbc = Rhino.CurveCurveIntersection (stlLineb, stlLinec,dblIntTol)
arrCCXPbc = Rhino.CurveCurveIntersection (stlLinePrevb, stlLinePrevc,dblIntTol)
If IsArray(arrCCXbc) And Not isArray (arrCCXPbc) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXbc(n,1)), rgb(0,0,255))
dblAngleb = dblAngleb * -1
dblAnglec = dblAnglec * -1
arrFinPtsb(i) = arrCCXbc(n,1)
arrFinPtsc(i) = arrCCXbc(n,1)
m = m + 1
End If

arrCCXbd = Rhino.CurveCurveIntersection (stlLineb, stlLined,dblIntTol)
arrCCXPbd = Rhino.CurveCurveIntersection (stlLinePrevb, stlLinePrevd,dblIntTol)
If IsArray(arrCCXbd) And Not isArray (arrCCXPbd) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXbd(n,1)), rgb(0,0,255))
dblAngleb = dblAngleb * -1
dblAngled = dblAngled * -1
arrFinPtsb(i) = arrCCXbd(n,1)
arrFinPtsd(i) = arrCCXbd(n,1)
m = m + 1
End If

arrCCXbe = Rhino.CurveCurveIntersection (stlLineb, stlLinee,dblIntTol)
arrCCXPbe = Rhino.CurveCurveIntersection (stlLinePrevb, stlLinePreve,dblIntTol)
If IsArray(arrCCXbe) And Not isArray (arrCCXPbe) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXbe(n,1)), rgb(0,0,255))
dblAngleb = dblAngleb * -1
dblAnglee = dblAnglee * -1
arrFinPtsb(i) = arrCCXbe(n,1)
arrFinPtse(i) = arrCCXbe(n,1)
m = m + 1
End If

arrCCXcd = Rhino.CurveCurveIntersection (stlLinec, stlLined,dblIntTol)
arrCCXPcd = Rhino.CurveCurveIntersection (stlLinePrevc, stlLinePrevd,dblIntTol)
If IsArray(arrCCXcd) And Not isArray (arrCCXPcd) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXcd(n,1)), rgb(0,0,255))
dblAnglec = dblAnglec * -1
dblAngled = dblAngled * -1
arrFinPtsc(i) = arrCCXcd(n,1)
arrFinPtsd(i) = arrCCXcd(n,1)
m = m + 1
End If

arrCCXce = Rhino.CurveCurveIntersection (stlLinec, stlLinee,dblIntTol)
arrCCXPce = Rhino.CurveCurveIntersection (stlLinePrevc, stlLinePreve,dblIntTol)
If IsArray(arrCCXce) And Not isArray (arrCCXPce) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXce(n,1)), rgb(0,0,255))
dblAnglec = dblAnglec * -1
dblAnglee = dblAnglee * -1
arrFinPtsc(i) = arrCCXce(n,1)
arrFinPtse(i) = arrCCXce(n,1)
m = m + 1
End If

arrCCXde = Rhino.CurveCurveIntersection (stlLined, stlLinee,dblIntTol)
arrCCXPde = Rhino.CurveCurveIntersection (stlLinePrevd, stlLinePreve,dblIntTol)
If IsArray(arrCCXde) And Not isArray (arrCCXPde) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXde(n,1)), rgb(0,0,255))
dblAngled = dblAngled * -1
dblAnglee = dblAnglee * -1
arrFinPtsd(i) = arrCCXde(n,1)
arrFinPtse(i) = arrCCXde(n,1)
m = m + 1
End If
Call Rhino.DeleteObject (stlLinea):Call Rhino.DeleteObject (stlLineb):Call Rhino.DeleteObject (stlLinec):Call Rhino.DeleteObject (stlLined):Call Rhino.DeleteObject (stlLinee)
Call Rhino.DeleteObject (stlLinePreva):Call Rhino.DeleteObject (stlLinePrevb):Call Rhino.DeleteObject (stlLinePrevc):Call Rhino.DeleteObject (stlLinePrevd):Call Rhino.DeleteObject (stlLinePreve)
End If

na=na+dblAnglea
nb=nb+dblAngleb
nc=nc+dblAnglec
nd=nd+dblAngled
ne=ne+dblAnglee
Next
k = (m-10)*25.5
If k <0 Then
k=0
End If

strCrva = Rhino.ObjectColor(Rhino.AddInterpCurve (arrFinPtsa),rgb(0,0,k)):strCrvb = Rhino.ObjectColor(Rhino.AddInterpCurve (arrFinPtsb),rgb(0,0,k)):strCrvc = Rhino.ObjectColor(Rhino.AddInterpCurve (arrFinPtsc),rgb(0,0,k)): strCrvd = Rhino.ObjectColor(Rhino.AddInterpCurve (arrFinPtsd),rgb(0,0,k)): strCrve = Rhino.ObjectColor(Rhino.AddInterpCurve (arrFinPtse),rgb(0,0,k))
‘Call AddPipe(arrFinPtsa,dblRad,k):Call AddPipe(arrFinPtsb,dblRad,k):Call AddPipe(arrFinPtsc,dblRad,k):Call AddPipe(arrFinPtsd,dblRad,k):Call AddPipe(arrFinPtse,dblRad,k)

‘Call Rhino.Command (“-text -20,-50 h 15 Intersections:_”&m&” “)
Call Rhino.Command (“selall “)
Call Rhino.Command (“move 0,0,0 0,200,0 “)
Call Rhino.Command (“selnone “)
Next
Call Rhino.Command (“show “)
Call Rhino.Command (“selall “)
Call Rhino.Command (“move 0,0,0 200,0,0 “)
Call Rhino.Command (“hide “)
Next
Call Rhino.Command (“Show “)
Call Rhino.Command (“selall “)
Call Rhino.Command (“move 0,0,0 -200,-200,0 “)
Call Rhino.Command (“selnone “)
Call Rhino.Command (“selpt “)
Call Rhino.Command (“hide “)
End Sub

Function AddPipe(arrMovPta,dblRad,k)
Dim strLine, strPipe
strLine = Rhino.AddCurve (arrMovPta)
Call Rhino.SelectObject (strLine)
Call Rhino.Command (“Pipe “&dblRad&” “&dblRad&” enter”)
strPipe = Rhino.LastObject
Call Rhino.ObjectColor (strPipe, rgb(0,0,k))
Call Rhino.Command (“Selnone “)
Call Rhino.DeleteObject (strLine)
End Function

Function random(intLow,intUp)
Randomize
random = (intUp-intLow) * rnd() + intLow
End Function

 

071112_MBearak_IntegratedPodWeaving

towerstructureforwebsite.jpg

towerstructureforwebsite2.jpg

Option Explicit
‘Script written by mark.bearak
‘Script copyrighted by dtls.architecture
‘Script version Monday, October 22, 2007 3:16:51 PM

Call Main()
Sub Main()
Dim h, i, j, k, n, m,  na, nb, nc, nd, ne, nf, counterab, counterbc, countercd, counterde, counteref, counterfa
Dim dblRadius, dblRadii, dblConv, dblRad, arrPtsa(), arrPtsb(), arrPtsc(), arrPtsd(), arrPtse(), arrPtsf(), dblTol, strLine
Dim stlLinea, stlLineb, stlLinec, stlLined, stlLinee, stlLinef, stlLinePreva, stlLinePrevb, stlLinePrevc, stlLinePrevd, stlLinePreve, stlLinePrevf, dblIntTol
Dim arrCCXab, arrCCXaf, arrCCXbc, arrCCXcd, arrCCXde, arrCCXef, dblDistab, dblDistbc, dblDistcd, dblDistde, dblDistef, dblDistfa
Dim arrCCXPab, arrCCXPaf, arrCCXPbc, arrCCXPcd, arrCCXPde, arrCCXPef, arrPlaneab, arrPlanebc, arrPlanecd, arrPlanede, arrPlaneef, arrPlanefa
Dim strCrva, strCrvb, strCrvc, strCrvd, strCrve, strCrvf, arrMidPtab, arrMidPtbc, arrMidPtcd, arrMidPtde, arrMidPtef, arrMidPtfa

Dim dblAnglea : dblAnglea = 1
Dim dblAngleb : dblAngleb = 1
Dim dblAnglec : dblAnglec = 1
Dim dblAngled : dblAngled = 1
Dim dblAnglee : dblAnglee = 1
Dim dblAnglef : dblAnglef = 1

Dim intUpper : intUpper = 120
dblRadii = 5
dblRad = 1
dblTol = 4
dblIntTol = 1
dblConv = 0.0174532925

Dim intLines : intLines = 12
intLines = 72/ intlines

For h = 0 To 5
For j = 0 To 5

Dim rndAnglea : rndAnglea = Random(0,1)*10
Dim rndAngleb : rndAngleb = Random(-1,0)*10
Dim rndAnglec : rndAnglec = Random(0,1)*10
Dim rndAngled : rndAngled = Random(-1,0)*10
Dim rndAnglee : rndAnglee = Random(0,1)*10
Dim rndAnglef : rndAnglef = Random(-1,0)*10

Dim rnda : rnda = Random(10,50) / rndAnglea
Dim rndb : rndb = Random(70,110) / rndAngleb
Dim rndc : rndc = Random(130,170) / rndAnglec
Dim rndd : rndd = Random(190,230) / rndAngled
Dim rnde : rnde = Random(250,290) / rndAnglee
Dim rndf : rndf = Random(310,350) / rndAnglef

na=0 : nb=0 : nc=0 : nd=0 : ne=0 : nf=0 : m = 0
counterab=0 : counterbc=0 : countercd=0 : counterde=0 : counteref=0 : counterfa=0
For i = 0 To intUpper
dblRadius = (sin(i/10)*20) + 60
ReDim Preserve arrPtsa(i)
ReDim Preserve arrPtsb(i)
ReDim Preserve arrPtsc(i)
ReDim Preserve arrPtsd(i)
ReDim Preserve arrPtse(i)
ReDim Preserve arrPtsf(i)

arrPtsa(i) = (array(cos((na+rnda)*rndAnglea*dblConv)*dblRadius, sin((na+rnda)*rndAnglea*dblConv)*dblRadius, i*10))
arrPtsb(i) = (array(cos((nb+rndb)*rndAngleb*dblConv)*dblRadius, sin((nb+rndb)*rndAngleb*dblConv)*dblRadius, i*10))
arrPtsc(i) = (array(cos((nc+rndc)*rndAnglec*dblConv)*dblRadius, sin((nc+rndc)*rndAnglec*dblConv)*dblRadius, i*10))
arrPtsd(i) = (array(cos((nd+rndd)*rndAngled*dblConv)*dblRadius, sin((nd+rndd)*rndAngled*dblConv)*dblRadius, i*10))
arrPtse(i) = (array(cos((ne+rnde)*rndAnglee*dblConv)*dblRadius, sin((ne+rnde)*rndAnglee*dblConv)*dblRadius, i*10))
arrPtsf(i) = (array(cos((nf+rndf)*rndAnglef*dblConv)*dblRadius, sin((nf+rndf)*rndAnglef*dblConv)*dblRadius, i*10))

If i>=2 Then

stlLinea = Rhino.AddInterpCurve (array(arrPtsa(i),arrPtsa(i-1)))
stlLineb = Rhino.AddInterpCurve (array(arrPtsb(i),arrPtsb(i-1)))
stlLinec = Rhino.AddInterpCurve (array(arrPtsc(i),arrPtsc(i-1)))
stlLined = Rhino.AddInterpCurve (array(arrPtsd(i),arrPtsd(i-1)))
stlLinee = Rhino.AddInterpCurve (array(arrPtse(i),arrPtse(i-1)))
stlLinef = Rhino.AddInterpCurve (array(arrPtsf(i),arrPtsf(i-1)))

stlLinePreva = Rhino.AddInterpCurve (array(arrPtsa(i-1),arrPtsa(i-2)))
stlLinePrevb = Rhino.AddInterpCurve (array(arrPtsb(i-1),arrPtsb(i-2)))
stlLinePrevc = Rhino.AddInterpCurve (array(arrPtsc(i-1),arrPtsc(i-2)))
stlLinePrevd = Rhino.AddInterpCurve (array(arrPtsd(i-1),arrPtsd(i-2)))
stlLinePreve = Rhino.AddInterpCurve (array(arrPtse(i-1),arrPtse(i-2)))
stlLinePrevf = Rhino.AddInterpCurve (array(arrPtsf(i-1),arrPtsf(i-2)))

dblDistab = rhino.Distance (arrPtsa(i),arrPtsb(i))
strLine = Rhino.AddLine (arrPtsa(i),arrPtsb(i))
arrMidPtab = Rhino.CurveMidPoint (strLine)
arrPlaneab = Rhino.PlaneFromPoints (arrMidPtab, array(0,0,i*10), arrPtsb(i))
Call Rhino.DeleteObject (strLine)

dblDistbc = rhino.Distance (arrPtsb(i),arrPtsc(i))
strLine = Rhino.AddLine (arrPtsb(i),arrPtsc(i))
arrMidPtbc = Rhino.CurveMidPoint (strLine)
arrPlanebc = Rhino.PlaneFromPoints (arrMidPtbc, array(0,0,i*10), arrPtsc(i))
Call Rhino.DeleteObject (strLine)

dblDistcd = rhino.Distance (arrPtsc(i),arrPtsd(i))
strLine = Rhino.AddLine (arrPtsc(i),arrPtsd(i))
arrMidPtcd = Rhino.CurveMidPoint (strLine)
arrPlanecd = Rhino.PlaneFromPoints (arrMidPtcd, array(0,0,i*10), arrPtsd(i))
Call Rhino.DeleteObject (strLine)

dblDistde = rhino.Distance (arrPtsd(i),arrPtse(i))
strLine = Rhino.AddLine (arrPtsd(i),arrPtse(i))
arrMidPtde = Rhino.CurveMidPoint (strLine)
arrPlanede = Rhino.PlaneFromPoints (arrMidPtde, array(0,0,i*10), arrPtse(i))
Call Rhino.DeleteObject (strLine)

dblDistef = rhino.Distance (arrPtse(i),arrPtsf(i))
strLine = Rhino.AddLine (arrPtse(i),arrPtsf(i))
arrMidPtef = Rhino.CurveMidPoint (strLine)
arrPlaneef = Rhino.PlaneFromPoints (arrMidPtef, array(0,0,i*10), arrPtsf(i))
Call Rhino.DeleteObject (strLine)

dblDistfa = rhino.Distance (arrPtsf(i),arrPtsa(i))
strLine = Rhino.AddLine (arrPtsf(i),arrPtsa(i))
arrMidPtfa = Rhino.CurveMidPoint (strLine)
arrPlanefa = Rhino.PlaneFromPoints (arrMidPtfa, array(0,0,i*10), arrPtsa(i))
Call Rhino.DeleteObject (strLine)

arrCCXab = Rhino.CurveCurveIntersection (stlLinea, stlLineb,dblIntTol)
arrCCXPab = Rhino.CurveCurveIntersection (stlLinePreva, stlLinePrevb,dblIntTol)
If IsArray(arrCCXab) And Not isArray (arrCCXPab) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXab(n,1)), rgb(0,0,255))
dblAnglea = dblAnglea * -1
dblAngleb = dblAngleb * -1
arrPtsa(i) = arrCCXab(n,1)
arrPtsb(i) = arrCCXab(n,1)
m = m + 1
counterab = counterab+1
End If

arrCCXaf = Rhino.CurveCurveIntersection (stlLinea, stlLinef,dblIntTol)
arrCCXPaf = Rhino.CurveCurveIntersection (stlLinePreva, stlLinePrevf,dblIntTol)
If IsArray(arrCCXaf) And Not isArray (arrCCXPaf) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXaf(n,1)), rgb(0,0,255))
dblAnglea = dblAnglea * -1
dblAnglef = dblAnglef * -1
arrPtsa(i) = arrCCXaf(n,1)
arrPtsf(i) = arrCCXaf(n,1)
m = m + 1
counterfa = counterfa+1
End If

arrCCXbc = Rhino.CurveCurveIntersection (stlLineb, stlLinec,dblIntTol)
arrCCXPbc = Rhino.CurveCurveIntersection (stlLinePrevb, stlLinePrevc,dblIntTol)
If IsArray(arrCCXbc) And Not isArray (arrCCXPbc) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXbc(n,1)), rgb(0,0,255))
dblAngleb = dblAngleb * -1
dblAnglec = dblAnglec * -1
arrPtsb(i) = arrCCXbc(n,1)
arrPtsc(i) = arrCCXbc(n,1)
m = m + 1
counterbc = counterbc+1
End If

arrCCXcd = Rhino.CurveCurveIntersection (stlLinec, stlLined,dblIntTol)
arrCCXPcd = Rhino.CurveCurveIntersection (stlLinePrevc, stlLinePrevd,dblIntTol)
If IsArray(arrCCXcd) And Not isArray (arrCCXPcd) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXcd(n,1)), rgb(0,0,255))
dblAnglec = dblAnglec * -1
dblAngled = dblAngled * -1
arrPtsc(i) = arrCCXcd(n,1)
arrPtsd(i) = arrCCXcd(n,1)
m = m + 1
countercd = countercd+1
End If

arrCCXde = Rhino.CurveCurveIntersection (stlLined, stlLinee,dblIntTol)
arrCCXPde = Rhino.CurveCurveIntersection (stlLinePrevd, stlLinePreve,dblIntTol)
If IsArray(arrCCXde) And Not isArray (arrCCXPde) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXde(n,1)), rgb(0,0,255))
dblAngled = dblAngled * -1
dblAnglee = dblAnglee * -1
arrPtsd(i) = arrCCXde(n,1)
arrPtse(i) = arrCCXde(n,1)
m = m + 1
counterde = counterde+1
End If

arrCCXef = Rhino.CurveCurveIntersection (stlLinee, stlLinef,dblIntTol)
arrCCXPef = Rhino.CurveCurveIntersection (stlLinePreve, stlLinePrevf,dblIntTol)
If IsArray(arrCCXef) And Not isArray (arrCCXPef) Then
Call Rhino.ObjectColor (Rhino.AddPoint (arrCCXef(n,1)), rgb(0,0,255))
dblAnglee = dblAnglee * -1
dblAnglef = dblAnglef * -1
arrPtse(i) = arrCCXef(n,1)
arrPtsf(i) = arrCCXef(n,1)
m = m + 1
counteref = counteref+1
End If

If counterab > 0 And counterab Mod 2 = 0 Then
Call Rhino.AddCircle (arrPlaneab, dblDistab/3)
End If

If counterbc > 0 And counterbc Mod 2 = 1 Then
Call Rhino.AddCircle (arrPlanebc, dblDistbc/3)
End If

If countercd > 0 And countercd Mod 2 = 1 Then
Call Rhino.AddCircle (arrPlanecd, dblDistcd/3)
End If

If counterde > 0 And counterde Mod 2 = 0 Then
Call Rhino.AddCircle (arrPlanede, dblDistde/3)
End If

If counteref > 0 And counteref Mod 2 = 1 Then
Call Rhino.AddCircle (arrPlaneef, dblDistef/3)
End If

If counterfa > 0 And counterfa Mod 2 = 0 Then
Call Rhino.AddCircle (arrPlanefa, dblDistfa/3)
End If

Call Rhino.DeleteObject (stlLinea):Call Rhino.DeleteObject (stlLineb):Call Rhino.DeleteObject (stlLinec):Call Rhino.DeleteObject (stlLined):Call Rhino.DeleteObject (stlLinee):Call Rhino.DeleteObject (stlLinef)
Call Rhino.DeleteObject (stlLinePreva):Call Rhino.DeleteObject (stlLinePrevb):Call Rhino.DeleteObject (stlLinePrevc):Call Rhino.DeleteObject (stlLinePrevd):Call Rhino.DeleteObject (stlLinePreve):Call Rhino.DeleteObject (stlLinePrevf)
End If

na=na+dblAnglea
nb=nb+dblAngleb
nc=nc+dblAnglec
nd=nd+dblAngled
ne=ne+dblAnglee
nf=nf+dblAnglef
Next
k = (m-30)*12.75
If k <0 Then
k=0
End If

strCrva = Rhino.AddCurve(arrPtsa,3):strCrvb = Rhino.AddCurve(arrPtsb,3):strCrvc = Rhino.AddCurve(arrPtsc,3):strCrvd = Rhino.AddCurve(arrPtsd,3):strCrve = Rhino.AddCurve(arrPtse,3):strCrvf = Rhino.AddCurve(arrPtsf,3)
‘Call AddPipe(arrFinPtsa,dblRad,k):Call AddPipe(arrFinPtsb,dblRad,k):Call AddPipe(arrFinPtsc,dblRad,k):Call AddPipe(arrFinPtsd,dblRad,k):Call AddPipe(arrFinPtse,dblRad,k):Call AddPipe(arrFinPtsf,dblRad,k)
‘Call Weaving(strCrva,intLines,dblRadii,intUpper,dblRad,k):Call Weaving(strCrvb,intLines,dblRadii,intUpper,dblRad,k):Call Weaving(strCrvc,intLines,dblRadii,intUpper,dblRad,k):Call Weaving(strCrvd,intLines,dblRadii,intUpper,dblRad,k):Call Weaving(strCrve,intLines,dblRadii,intUpper,dblRad,k):Call Weaving(strCrvf,intLines,dblRadii,intUpper,dblRad,j)

Call Rhino.Command (“-text -40,-100 h 15 Intersections:_”&m&” “)
Call Rhino.Command (“selall “) : Call Rhino.Command (“move 0,0,0 0,400,0 “) : Call Rhino.Command (“selnone “)
Next
Call Rhino.Command (“show “) : Call Rhino.Command (“selall “) : Call Rhino.Command (“move 0,0,0 400,0,0 “) : Call Rhino.Command (“hide “)
Next
Call Rhino.Command (“Show “) : Call Rhino.Command (“selall “) : Call Rhino.Command (“move 0,0,0 -400,-400,0 “) : Call Rhino.Command (“selnone “)
‘Call Rhino.Command (“selpt “) : Call Rhino.Command (“hide “)
End Sub

Function AddPipe(arrMovPta,dblRad,k)
Dim strLine, strPipe
strLine = Rhino.AddInterpCurve (arrMovPta)
Call Rhino.SelectObject (strLine)
Call Rhino.Command (“Pipe “&dblRad&” “&dblRad&” enter”)
strPipe = Rhino.LastObject
Call Rhino.ObjectColor (strPipe, rgb(0,k,0))
Call Rhino.Command (“Selnone “)
Call Rhino.DeleteObject (strLine)
End Function

Function random(intLow,intUp)
Randomize
random = (intUp-intLow) * rnd() + intLow
End Function

Function Weaving(ArrayOfPoints,intLines,dblRadii,k,dblRad,j)
Dim h, i, l, n
Dim dblConv, arrpt, arrPts, strPt, arrPtsa(), arrPtsb(),arrFlrPts(), arrFlrPt(), strObj
arrPts = Rhino.DivideCurve (ArrayOfPoints, k)
Call Rhino.DeleteObject(ArrayOfPoints)
dblConv = 0.0174532925
Dim dblLocX
Dim dblLocY
Dim dblLocZ
Dim dblRadius
Dim intStep : intStep = intLines
Dim dblRot : dblRot = 360/(36/intStep)
Dim intOffset : intOffset = intStep/(intStep*4)
Dim dblMin : DblMin = fix(random(10,80))
Dim dblMax : DblMax = DblMin+fix(random(20,40))
Dim dblInterval : dblInterval = (dblMax-DblMin)/3
Dim dblGrowth : dblGrowth = (dblMax-DblMin)/5
For h = 0 To 35 Step intStep
n = 0
For Each arrPt In arrPts
If n >= DblMin And n <= DblMax Then
dblRadius = Sin((n-DblMin)/dblInterval)*dblGrowth*Sin((n-DblMin)/dblInterval)*dblGrowth+dblRadii
Else
dblRadius = dblRadii
End If
‘Call Rhino.AddPoint (arrPt)
ReDim Preserve arrPtsa(n)
ReDim Preserve arrPtsb(n)
dblLocX = arrPt(0)
dblLocY = arrPt(1)
dblLocZ = arrPt(2)
If n Mod 2 = 0 Then
arrPtsa(n) = (array(cos((h+intOffset)*10*dblConv)*dblRadius+dblLocX, (sin((h+intOffset)*10*dblConv)*dblRadius)*-1+dblLocY, dblLocZ))
arrPtsb(n) = (array(cos((h-intOffset)*10*dblConv)*dblRadius+dblLocX, (sin((h-intOffset)*10*dblConv)*dblRadius)*-1+dblLocY, dblLocZ))
Else
arrPtsa(n) = (array(cos((h+(intStep/2)-intOffset)*10*dblConv)*dblRadius+dblLocX, (sin((h+(intStep/2)-intOffset)*10*dblConv)*dblRadius)*-1+dblLocY, dblLocZ))
arrPtsb(n) = (array(cos((h-(intStep/2)+intOffset)*10*dblConv)*dblRadius+dblLocX, (sin((h-(intStep/2)+intOffset)*10*dblConv)*dblRadius)*-1+dblLocY, dblLocZ))
End If
n=n+1
Next
strObj = Rhino.AddinterpCurve (arrPtsa)
Call  Rhino.ObjectColor (strObj,RGB (0,0,0))
strObj = Rhino.AddinterpCurve (arrPtsb)
Call  Rhino.ObjectColor (strObj,RGB (0,0,0))
‘Call AddPipe(arrPtsa,dblRad,j) : Call AddPipe(arrPtsb,dblRad,j)
Next

n = 0
For Each arrPt In arrPts
ReDim Preserve arrFlrPt(n)
If n >= DblMin And n <= DblMax Then
dblRadius = Sin((n-DblMin)/dblInterval)*dblGrowth*Sin((n-DblMin)/dblInterval)*dblGrowth+dblRadii
dblLocX = arrPt(0)
dblLocY = arrPt(1)
dblLocZ = arrPt(2)
If n Mod 2 = 0 Then
For l = 0 To intStep*2
ReDim Preserve arrFlrPts(l)
If l Mod 2 = 0 Then
arrFlrPts(l) = array(cos(l*(dblRot/2)*dblConv)*dblRadius+dblLocX, (sin(l*(dblRot/2)*dblConv)*dblRadius)*-1+dblLocY, dblLocZ)
Else
arrFlrPts(l) = array(cos(l*(dblRot/2)*dblConv)*(dblRadius/1.4)+dblLocX, (sin(l*(dblRot/2)*dblConv)*(dblRadius/1.4))*-1+dblLocY, dblLocZ)
End If
Next
strObj = Rhino.AddinterpCurve (arrFlrPts)
Call Rhino.SelectObject (strObj)
Call Rhino.Command (“planarSrf “)
Call Rhino.Command (“selnone “)
Else
For l = 0 To intStep*2
ReDim Preserve arrFlrPts(l)
If l Mod 2 = 0 Then
arrFlrPts(l) = array(cos(l*(dblRot/2)*dblConv)*(dblRadius/1.4)+dblLocX, (sin(l*(dblRot/2)*dblConv)*(dblRadius/1.4))*-1+dblLocY, dblLocZ)
Else
arrFlrPts(l) = array(cos(l*(dblRot/2)*dblConv)*dblRadius+dblLocX, (sin(l*(dblRot/2)*dblConv)*dblRadius)*-1+dblLocY, dblLocZ)
End If
Next
strObj = Rhino.AddinterpCurve (arrFlrPts)
Call Rhino.SelectObject (strObj)
Call Rhino.Command (“planarSrf “)
Call Rhino.Command (“selnone “)
End If
End If
n=n+1
Next
‘Call AddPipe(arrPtsa,dblRad,j) : Call AddPipe(arrPtsb,dblRad,j)
End Function

 

071024_MBearak_Weaving Cylinder

meshingcylinder3.jpg

meshingcylinder1.jpg

Option Explicit
‘Script written by mark bearak
‘Script copyrighted by dtls.architecture
‘Script version Monday, October 22, 2007 3:16:51 PM

Call Main()
Sub Main()
Dim h, i
Dim dblRadius, vecDir, intFreq, dblConv, n, dblInflect, arrMovPta(), arrMovPtb(), arrMovPtc(), arrMovPtd(), arrMovPte(), blnEven
Dim dblRad : dblRad = 1
Dim dblSpread : dblSpread = 6
Dim dblCntX, dblCntY, dblCntZ
dblConv = 0.0174532925
For h = 0 To 20
If (h Mod 2=1) Then
n = 0
intFreq = 0
dblRadius = 15
dblInflect = dblRadius/10
ReDim Preserve arrSrf(h)
For i = 0 To 36
ReDim Preserve arrMovPtd(i)
ReDim Preserve arrMovPte(i)
If (i Mod 4 = 0)Then
blnEven = 1
Else
blnEven = -1
End If
DblCntX = 0
DblCntY = 0
DblCntZ = h*7

If (i Mod 2 = 0) Then

ReDim Preserve arrMovPta(n)
ReDim Preserve arrMovPtb(n)
ReDim Preserve arrMovPtc(n)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ-(dblRad*(dblSpread/2))),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ-(dblRad*(dblSpread/2))))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, 90*blnEven, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread)
arrMovPta(n) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ-(dblRad*(dblSpread/2))),vecDir)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, -90*blnEven, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread)
arrMovPtb(n) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ+(dblRad*(dblSpread/2))),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ+(dblRad*(dblSpread/2))))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, 90*blnEven, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread)
arrMovPtc(n) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ+(dblRad*(dblSpread/2))),vecDir)
n = n + 1
End If

If (i Mod 4 = 0) Then
vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, 90, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread/3)
arrMovPtd(i) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, -90, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread/3)
arrMovPte(i) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)
Else
If (i Mod 4 = 1) Then
arrMovPtd(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ+(dblRad*dblSpread*1.5))))
arrMovPte(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ-(dblRad*dblSpread*1.5))))
Else
If (i Mod 4 = 2) Then
vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, -90, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread/3)
arrMovPtd(i) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, 90, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread/3)
arrMovPte(i) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)
Else
arrMovPtd(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ-(dblRad*dblSpread*1.5))))
arrMovPte(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ+(dblRad*dblSpread*1.5))))
End If
End If
End If
Next
Call AddPipe(arrMovPta,dblRad)
Call AddPipe(arrMovPtb,dblRad)
Call AddPipe(arrMovPtc,dblRad)
Call AddPipe(arrMovPtd,dblRad)
Call AddPipe(arrMovPte,dblRad)
End If
Next
End Sub

Function AddPipe(arrMovPta,dblRad)
Dim strLine
strLine = Rhino.AddInterpCurve (arrMovPta)
Call Rhino.SelectObject (strLine)
Call Rhino.Command (“Pipe “&dblRad&” “&dblRad&” enter”)
Call Rhino.Command (“Selnone “)
End Function

 

071024_MBearak_Dirrrrrrrrty Weaving

dirrtymeshing1.jpg

dirrtymeshing2.jpg

Option Explicit
‘Script written by mark.bearak
‘Script copyrighted by dtls.architecture
‘Script version Monday, October 22, 2007 3:16:51 PM

Call Main()
Sub Main()
Dim h, i
Dim dblRadius, vecDir, intFreq, dblConv, n, dblInflect, arrMovPta(), arrMovPtb(), arrMovPtc(), arrMovPtd(), arrMovPte(), blnEven
Dim dblRad : dblRad = 1
Dim dblSpread : dblSpread = 6
Dim dblCntX, dblCntY, dblCntZ
dblConv = 0.0174532925
For h = 0 To 20
If (h Mod 2=1) Then
n = 0
dblRadius = 20
dblInflect = dblRadius/10
ReDim Preserve arrSrf(h)
For i = 0 To 36
ReDim Preserve arrMovPtd(i)
ReDim Preserve arrMovPte(i)
If (i Mod 4 = 0)Then
blnEven = 1
Else
blnEven = -1
End If
DblCntX = 0
DblCntY = 0
DblCntZ = h*7

If (i Mod 2 = 0) Then
intFreq = h*10
ReDim Preserve arrMovPta(n)
ReDim Preserve arrMovPtb(n)
ReDim Preserve arrMovPtc(n)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ-(dblSpread/2)),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ-(dblSpread/2)))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, 90*blnEven, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread)
arrMovPta(n) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ-(dblSpread/2)),vecDir)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, -90*blnEven, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread)
arrMovPtb(n) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ+(dblSpread/2)),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ+(dblSpread/2)))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, 90*blnEven, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread)
arrMovPtc(n) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ+(dblSpread/2)),vecDir)
n = n + 1
End If

If (i Mod 4 = 0) Then
intFreq = h*10
vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, 90, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread/3)
arrMovPtd(i) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, -90, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread/3)
arrMovPte(i) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)
Else
If (i Mod 4 = 1) Then
intFreq = 10*(h+1)
DblCntZ = ((h+1)*7)+(dblSpread/2)
arrMovPtd(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ)))
intFreq = 10*(h-1)
DblCntZ = ((h-1)*7)-(dblSpread/2)
arrMovPte(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(cos((i-1)*10*dblConv)*dblRadius*((sin((i-1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i-1)*10*dblConv)*dblRadius*((sin((i-1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ)))
Else
If (i Mod 4 = 2) Then
intFreq = h*10
vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, -90, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread/3)
arrMovPtd(i) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)

vecDir = Rhino.VectorCreate (array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),_
array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ))
vecDir = rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorRotate (vecDir, 90, array(0,0,1))
vecDir = rhino.VectorScale(vecDir, dblSpread/3)
arrMovPte(i) = Rhino.PointAdd(array(cos(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin(i*10*dblConv)*dblRadius*((sin(i*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ),vecDir)
Else
intFreq = 10*(h-1)
DblCntZ = ((h-1)*7)-(dblSpread/2)
arrMovPtd(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(cos((i-1)*10*dblConv)*dblRadius*((sin((i-1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i-1)*10*dblConv)*dblRadius*((sin((i-1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ)))
intFreq = 10*(h+1)
DblCntZ = ((h+1)*7)+(dblSpread/2)
arrMovPte(i) = Rhino.PointCoordinates (Rhino.AddPoint (array(cos((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntX, sin((i+1)*10*dblConv)*dblRadius*((sin((i+1)*intFreq*dblConv)+1)/3+dblInflect)+DblCntY, 0+DblCntZ)))
End If
End If
End If
Next
Call AddPipe(arrMovPta,dblRad)
Call AddPipe(arrMovPtb,dblRad)
Call AddPipe(arrMovPtc,dblRad)
Call AddPipe(arrMovPtd,dblRad)
Call AddPipe(arrMovPte,dblRad)
End If
Next
End Sub

Function AddPipe(arrMovPta,dblRad)
Dim strLine
strLine = Rhino.AddInterpCurve (arrMovPta)
Call Rhino.SelectObject (strLine)
Call Rhino.Command (“Pipe “&dblRad&” “&dblRad&” enter”)
Call Rhino.Command (“Selnone “)
End Function

 

 

071119_MBearak_Cohesive Pods and structure

 

Option Explicit
‘Script written by mark.bearak
‘Script copyrighted by dtls.architecture
‘Script version Monday, October 22, 2007 3:16:51 PM

Call Main()
Sub Main()
Dim h, i, j, k, n, m,  na, nb, nc, nd, ne, nf, counterab, counterbc, countercd, counterde, counteref, counterfa
Dim dblRadius, dblRadii, dblConv, dblRad, arrPtsa(), arrPtsb(), arrPtsc(), arrPtsd(), arrPtse(), arrPtsf(), dblTol, strLine
Dim stlLinea, stlLineb, stlLinec, stlLined, stlLinee, stlLinef, stlLinePreva, stlLinePrevb, stlLinePrevc, stlLinePrevd, stlLinePreve, stlLinePrevf, dblIntTol
Dim arrCCXab, arrCCXaf, arrCCXbc, arrCCXcd, arrCCXde, arrCCXef, dblDistab, dblDistbc, dblDistcd, dblDistde, dblDistef, dblDistfa
Dim arrCCXPab, arrCCXPaf, arrCCXPbc, arrCCXPcd, arrCCXPde, arrCCXPef, dblAngle, dblAngle1, dblAngle2
Dim strCrva, strCrvb, strCrvc, strCrvd, strCrve, strCrvf, arrMidPtab, arrMidPtbc, arrMidPtcd, arrMidPtde, arrMidPtef, arrMidPtfa
Dim arrRadiia(), arrRadiib(), arrRadiic(), arrRadiid(), arrRadiie(), arrRadiif(), arrCenterLoca(), arrCenterLocb(), arrCenterLocc(), arrCenterLocd(), arrCenterLoce(), arrCenterLocf()

Dim dblAnglea : dblAnglea = 1
Dim dblAngleb : dblAngleb = 1
Dim dblAnglec : dblAnglec = 1
Dim dblAngled : dblAngled = 1
Dim dblAnglee : dblAnglee = 1
Dim dblAnglef : dblAnglef = 1

Dim intUpper : intUpper = 120
dblRadii = 5
dblRad = 1
dblTol = 4
dblIntTol = 1
dblConv = 0.0174532925

Dim intLinesa : intLinesa = 24
Dim intLinesb : intLinesb = 12
intLinesa = 72/intLinesa
intLinesb = 72/intLinesb

Call Rhino.EnableRedraw (False)
For h = 0 To 1
For j = 0 To 1
Dim rndAnglea : rndAnglea = Random(0.5,1)*10
Dim rndAngleb : rndAngleb = Random(-1,-0.5)*10
Dim rndAnglec : rndAnglec = Random(0.5,1)*10
Dim rndAngled : rndAngled = Random(-1,-0.5)*10
Dim rndAnglee : rndAnglee = Random(0.5,1)*10
Dim rndAnglef : rndAnglef = Random(-1,-0.5)*10

Dim rnda : rnda = Random(10,50) / rndAnglea
Dim rndb : rndb = Random(70,110) / rndAngleb
Dim rndc : rndc = Random(130,170) / rndAnglec
Dim rndd : rndd = Random(190,230) / rndAngled
Dim rnde : rnde = Random(250,290) / rndAnglee
Dim rndf : rndf = Random(310,350) / rndAnglef

na=0 : nb=0 : nc=0 : nd=0 : ne=0 : nf=0 : m = 0
counterab=0 : counterbc=0 : countercd=0 : counterde=0 : counteref=0 : counterfa=0
For i = 0 To intUpper
dblRadius = (sin(i/10)*20) + 60
ReDim Preserve arrPtsa(i)
ReDim Preserve arrPtsb(i)
ReDim Preserve arrPtsc(i)
ReDim Preserve arrPtsd(i)
ReDim Preserve arrPtse(i)
ReDim Preserve arrPtsf(i)
ReDim Preserve arrRadiia(i)
ReDim Preserve arrRadiib(i)
ReDim Preserve arrRadiic(i)
ReDim Preserve arrRadiid(i)
ReDim Preserve arrRadiie(i)
ReDim Preserve arrRadiif(i)
ReDim Preserve arrCenterLoca(i)
ReDim Preserve arrCenterLocb(i)
ReDim Preserve arrCenterLocc(i)
ReDim Preserve arrCenterLocd(i)
ReDim Preserve arrCenterLoce(i)
ReDim Preserve arrCenterLocf(i)

arrPtsa(i) = (array(cos((na+rnda)*rndAnglea*dblConv)*dblRadius, sin((na+rnda)*rndAnglea*dblConv)*dblRadius, i*10))
arrPtsb(i) = (array(cos((nb+rndb)*rndAngleb*dblConv)*dblRadius, sin((nb+rndb)*rndAngleb*dblConv)*dblRadius, i*10))
arrPtsc(i) = (array(cos((nc+rndc)*rndAnglec*dblConv)*dblRadius, sin((nc+rndc)*rndAnglec*dblConv)*dblRadius, i*10))
arrPtsd(i) = (array(cos((nd+rndd)*rndAngled*dblConv)*dblRadius, sin((nd+rndd)*rndAngled*dblConv)*dblRadius, i*10))
arrPtse(i) = (array(cos((ne+rnde)*rndAnglee*dblConv)*dblRadius, sin((ne+rnde)*rndAnglee*dblConv)*dblRadius, i*10))
arrPtsf(i) = (array(cos((nf+rndf)*rndAnglef*dblConv)*dblRadius, sin((nf+rndf)*rndAnglef*dblConv)*dblRadius, i*10))

If i>=2 Then

stlLinea = Rhino.AddInterpCurve (array(arrPtsa(i),arrPtsa(i-1)))
stlLineb = Rhino.AddInterpCurve (array(arrPtsb(i),arrPtsb(i-1)))
stlLinec = Rhino.AddInterpCurve (array(arrPtsc(i),arrPtsc(i-1)))
stlLined = Rhino.AddInterpCurve (array(arrPtsd(i),arrPtsd(i-1)))
stlLinee = Rhino.AddInterpCurve (array(arrPtse(i),arrPtse(i-1)))
stlLinef = Rhino.AddInterpCurve (array(arrPtsf(i),arrPtsf(i-1)))

stlLinePreva = Rhino.AddInterpCurve (array(arrPtsa(i-1),arrPtsa(i-2)))
stlLinePrevb = Rhino.AddInterpCurve (array(arrPtsb(i-1),arrPtsb(i-2)))
stlLinePrevc = Rhino.AddInterpCurve (array(arrPtsc(i-1),arrPtsc(i-2)))
stlLinePrevd = Rhino.AddInterpCurve (array(arrPtsd(i-1),arrPtsd(i-2)))
stlLinePreve = Rhino.AddInterpCurve (array(arrPtse(i-1),arrPtse(i-2)))
stlLinePrevf = Rhino.AddInterpCurve (array(arrPtsf(i-1),arrPtsf(i-2)))

arrCCXab = Rhino.CurveCurveIntersection (stlLinea, stlLineb,dblIntTol)
arrCCXPab = Rhino.CurveCurveIntersection (stlLinePreva, stlLinePrevb,dblIntTol)
If IsArray(arrCCXab) And Not isArray (arrCCXPab) Then
dblAnglea = dblAnglea * -1
dblAngleb = dblAngleb * -1
arrPtsa(i) = arrCCXab(n,1)
arrPtsb(i) = arrCCXab(n,1)
m = m + 1
counterab = counterab+1
End If

arrCCXaf = Rhino.CurveCurveIntersection (stlLinea, stlLinef,dblIntTol)
arrCCXPaf = Rhino.CurveCurveIntersection (stlLinePreva, stlLinePrevf,dblIntTol)
If IsArray(arrCCXaf) And Not isArray (arrCCXPaf) Then
dblAnglea = dblAnglea * -1
dblAnglef = dblAnglef * -1
arrPtsa(i) = arrCCXaf(n,1)
arrPtsf(i) = arrCCXaf(n,1)
m = m + 1
counterfa = counterfa+1
End If

arrCCXbc = Rhino.CurveCurveIntersection (stlLineb, stlLinec,dblIntTol)
arrCCXPbc = Rhino.CurveCurveIntersection (stlLinePrevb, stlLinePrevc,dblIntTol)
If IsArray(arrCCXbc) And Not isArray (arrCCXPbc) Then
dblAngleb = dblAngleb * -1
dblAnglec = dblAnglec * -1
arrPtsb(i) = arrCCXbc(n,1)
arrPtsc(i) = arrCCXbc(n,1)
m = m + 1
counterbc = counterbc+1
End If

arrCCXcd = Rhino.CurveCurveIntersection (stlLinec, stlLined,dblIntTol)
arrCCXPcd = Rhino.CurveCurveIntersection (stlLinePrevc, stlLinePrevd,dblIntTol)
If IsArray(arrCCXcd) And Not isArray (arrCCXPcd) Then
dblAnglec = dblAnglec * -1
dblAngled = dblAngled * -1
arrPtsc(i) = arrCCXcd(n,1)
arrPtsd(i) = arrCCXcd(n,1)
m = m + 1
countercd = countercd+1
End If

arrCCXde = Rhino.CurveCurveIntersection (stlLined, stlLinee,dblIntTol)
arrCCXPde = Rhino.CurveCurveIntersection (stlLinePrevd, stlLinePreve,dblIntTol)
If IsArray(arrCCXde) And Not isArray (arrCCXPde) Then
dblAngled = dblAngled * -1
dblAnglee = dblAnglee * -1
arrPtsd(i) = arrCCXde(n,1)
arrPtse(i) = arrCCXde(n,1)
m = m + 1
counterde = counterde+1
End If

arrCCXef = Rhino.CurveCurveIntersection (stlLinee, stlLinef,dblIntTol)
arrCCXPef = Rhino.CurveCurveIntersection (stlLinePreve, stlLinePrevf,dblIntTol)
If IsArray(arrCCXef) And Not isArray (arrCCXPef) Then
dblAnglee = dblAnglee * -1
dblAnglef = dblAnglef * -1
arrPtse(i) = arrCCXef(n,1)
arrPtsf(i) = arrCCXef(n,1)
m = m + 1
counteref = counteref+1
End If

Call Rhino.DeleteObject (stlLinea):Call Rhino.DeleteObject (stlLineb):Call Rhino.DeleteObject (stlLinec):Call Rhino.DeleteObject (stlLined):Call Rhino.DeleteObject (stlLinee):Call Rhino.DeleteObject (stlLinef)
Call Rhino.DeleteObject (stlLinePreva):Call Rhino.DeleteObject (stlLinePrevb):Call Rhino.DeleteObject (stlLinePrevc):Call Rhino.DeleteObject (stlLinePrevd):Call Rhino.DeleteObject (stlLinePreve):Call Rhino.DeleteObject (stlLinePrevf)
End If

dblDistab = rhino.Distance (array(0,0,i*10),arrPtsa(i))
dblAngle2 = Rhino.Angle2 (array(array(0,0,i*10),array(10,0,i*10)),array(array(0,0,i*10),arrPtsa(i)))
dblAngle1 = Rhino.Angle2 (array(array(0,0,i*10),array(10,0,i*10)),array(array(0,0,i*10),arrPtsb(i)))
If dblAngle2(0) < 0 Then
dblAngle2(0) = dblAngle2(0) + 360
End If
If dblAngle1(0) < 0 Then
dblAngle1(0) = dblAngle1(0) + 360
End If
dblAngle = (dblAngle1(0) + dblAngle2(0))/2
arrMidPtab = Rhino.Polar(array(0,0,i*10), dblAngle, dblDistab)
dblDistab = (Rhino.Distance (arrMidPtab,arrPtsa(i)))*2

dblDistbc = rhino.Distance (array(0,0,i*10),arrPtsb(i))
dblAngle2 = Rhino.Angle2 (array(array(0,0,i*10),array(10,10,i*10)),array(array(0,0,i*10),arrPtsb(i)))
dblAngle1 = Rhino.Angle2 (array(array(0,0,i*10),array(10,10,i*10)),array(array(0,0,i*10),arrPtsc(i)))
If dblAngle2(0) < 0 Then
dblAngle2(0) = dblAngle2(0) + 360
End If
If dblAngle1(0) < 0 Then
dblAngle1(0) = dblAngle1(0) + 360
End If
dblAngle = ((dblAngle1(0) + dblAngle2(0))/2)+45
arrMidPtbc = Rhino.Polar(array(0,0,i*10), dblAngle, dblDistbc)
dblDistbc = (Rhino.Distance (arrMidPtbc,arrPtsb(i)))*2

dblDistcd = rhino.Distance (array(0,0,i*10),arrPtsc(i))
dblAngle2 = Rhino.Angle2 (array(array(0,0,i*10),array(0,10,i*10)),array(array(0,0,i*10),arrPtsc(i)))
dblAngle1 = Rhino.Angle2 (array(array(0,0,i*10),array(0,10,i*10)),array(array(0,0,i*10),arrPtsd(i)))
If dblAngle2(0) < 0 Then
dblAngle2(0) = dblAngle2(0) + 360
End If
If dblAngle1(0) < 0 Then
dblAngle1(0) = dblAngle1(0) + 360
End If
dblAngle = ((dblAngle1(0) + dblAngle2(0))/2)+90
arrMidPtcd = Rhino.Polar(array(0,0,i*10), dblAngle, dblDistcd)
dblDistcd = (Rhino.Distance (arrMidPtcd,arrPtsc(i)))*2

dblDistde = rhino.Distance (array(0,0,i*10),arrPtsd(i))
dblAngle2 = Rhino.Angle2 (array(array(0,0,i*10),array(-10,10,i*10)),array(array(0,0,i*10),arrPtsd(i)))
dblAngle1 = Rhino.Angle2 (array(array(0,0,i*10),array(-10,10,i*10)),array(array(0,0,i*10),arrPtse(i)))
If dblAngle2(0) < 0 Then
dblAngle2(0) = dblAngle2(0) + 360
End If
If dblAngle1(0) < 0 Then
dblAngle1(0) = dblAngle1(0) + 360
End If
dblAngle = ((dblAngle1(0) + dblAngle2(0))/2)+135
arrMidPtde = Rhino.Polar(array(0,0,i*10), dblAngle, dblDistde)
dblDistde = (Rhino.Distance (arrMidPtde,arrPtsd(i)))*2

dblDistef = rhino.Distance (array(0,0,i*10),arrPtse(i))
dblAngle2 = Rhino.Angle2 (array(array(0,0,i*10),array(-10,0,i*10)),array(array(0,0,i*10),arrPtse(i)))
dblAngle1 = Rhino.Angle2 (array(array(0,0,i*10),array(-10,0,i*10)),array(array(0,0,i*10),arrPtsf(i)))
If dblAngle2(0) < 0 Then
dblAngle2(0) = dblAngle2(0) + 360
End If
If dblAngle1(0) < 0 Then
dblAngle1(0) = dblAngle1(0) + 360
End If
dblAngle = ((dblAngle1(0) + dblAngle2(0))/2)+180
arrMidPtef = Rhino.Polar(array(0,0,i*10), dblAngle, dblDistef)
dblDistef = (Rhino.Distance (arrMidPtef,arrPtse(i)))*2

dblDistfa = rhino.Distance (array(0,0,i*10),arrPtsf(i))
dblAngle2 = Rhino.Angle2 (array(array(0,0,i*10),array(-10,-10,i*10)),array(array(0,0,i*10),arrPtsf(i)))
dblAngle1 = Rhino.Angle2 (array(array(0,0,i*10),array(-10,-10,i*10)),array(array(0,0,i*10),arrPtsa(i)))
If dblAngle2(0) < 0 Then
dblAngle2(0) = dblAngle2(0) + 360
End If
If dblAngle1(0) < 0 Then
dblAngle1(0) = dblAngle1(0) + 360
End If
dblAngle = ((dblAngle1(0) + dblAngle2(0))/2)+225
arrMidPtfa = Rhino.Polar(array(0,0,i*10), dblAngle, dblDistfa)
dblDistfa = (Rhino.Distance (arrMidPtfa,arrPtsf(i)))*2

If counterab Mod 3 = 0 Then
arrRadiia(i) = dblDistab+dblradii
arrCenterLoca(i) = arrMidPtab
Else
arrRadiia(i) = dblRadii
arrCenterLoca(i) = arrPtsa(i)
End If

If counterbc Mod 2 = 1 Then
arrRadiib(i) = dblDistbc+dblradii
arrCenterLocb(i) = arrMidPtbc
Else
arrRadiib(i) = dblRadii
arrCenterLocb(i) = arrPtsb(i)
End If

If countercd Mod 2 = 0 Then
arrRadiic(i) = dblDistcd+dblradii
arrCenterLocc(i) = arrMidPtcd
Else
arrRadiic(i) = dblRadii
arrCenterLocc(i) = arrPtsc(i)
End If

If counterde Mod 3 = 1 Then
arrRadiid(i) = dblDistde+dblradii
arrCenterLocd(i) = arrMidPtde
Else
arrRadiid(i) = dblRadii
arrCenterLocd(i) = arrPtsd(i)
End If

If counteref Mod 2 = 0 Then
arrRadiie(i) = dblDistef+dblradii
arrCenterLoce(i) = arrMidPtef
Else
arrRadiie(i) = dblRadii
arrCenterLoce(i) = arrPtse(i)
End If

If counterfa Mod 2 = 1 Then
arrRadiif(i) = dblDistfa+dblradii
arrCenterLocf(i) = arrMidPtfa
Else
arrRadiif(i) = dblRadii
arrCenterLocf(i) = arrPtsf(i)
End If
na=na+dblAnglea
nb=nb+dblAngleb
nc=nc+dblAnglec
nd=nd+dblAngled
ne=ne+dblAnglee
nf=nf+dblAnglef
Next

k = (m-30)*12.75
If k <0 Then
k=0
End If

strCrva = Rhino.AddCurve(arrPtsa,3):strCrvb = Rhino.AddCurve(arrPtsb,3):strCrvc = Rhino.AddCurve(arrPtsc,3):strCrvd = Rhino.AddCurve(arrPtsd,3):strCrve = Rhino.AddCurve(arrPtse,3):strCrvf = Rhino.AddCurve(arrPtsf,3)
Call Weaving(strCrva,intLinesb,dblRadii,k,intUpper,dblRad) : Call Weaving(strCrvb,intLinesb,dblRadii,k,intUpper,dblRad):Call Weaving(strCrvc,intLinesb,dblRadii,k,intUpper,dblRad):Call Weaving(strCrvd,intLinesb,dblRadii,k,intUpper,dblRad):Call Weaving(strCrve,intLinesb,dblRadii,k,intUpper,dblRad):Call Weaving(strCrvf,intLinesb,dblRadii,k,intUpper,dblRad)
Call Weavinga(arrCenterLoca,arrRadiia,intLinesa,intUpper,dblRadii,k) : Call Weavinga(arrCenterLocb,arrRadiib,intLinesa,intUpper,dblRadii,k) : Call Weavinga(arrCenterLocc,arrRadiic,intLinesa,intUpper,dblRadii,k) : Call Weavinga(arrCenterLocd,arrRadiid,intLinesa,intUpper,dblRadii,k) : Call Weavinga(arrCenterLoce,arrRadiie,intLinesa,intUpper,dblRadii,k) : Call Weavinga(arrCenterLocf,arrRadiif,intLinesa,intUpper,dblRadii,k)
‘Call AddPipe(arrFinPtsa,dblRad,k):Call AddPipe(arrFinPtsb,dblRad,k):Call AddPipe(arrFinPtsc,dblRad,k):Call AddPipe(arrFinPtsd,dblRad,k):Call AddPipe(arrFinPtse,dblRad,k):Call AddPipe(arrFinPtsf,dblRad,k)

Call Rhino.ObjectColor (Rhino.AddText (“Intersections:_”&m, array(-40,-100), 15),rgb(0,k,0))
‘Call Rhino.ObjectColor (Rhino.Command (“-text -40,-100 h 15 Intersections:_”&m&” “),rgb(0,k,0))
Call Rhino.Command (“selall “) : Call Rhino.Command (“move 0,0,0 0,400,0 “) : Call Rhino.Command (“selnone “)
Next
Call Rhino.Command (“show “) : Call Rhino.Command (“selall “) : Call Rhino.Command (“move 0,0,0 400,0,0 “) : Call Rhino.Command (“hide “)
Next
Call Rhino.Command (“Show “) : Call Rhino.Command (“selall “) : Call Rhino.Command (“move 0,0,0 -400,-400,0 “) : Call Rhino.Command (“selnone “)
‘Call Rhino.Command (“selpt “) : Call Rhino.Command (“hide “)
Call Rhino.EnableRedraw (True)
End Sub

Function Weaving(ArrayOfPoints,intLinesa,dblRadii,j,k,dblRad)
Dim h, i, l, n
Dim dblConv, arrpt, arrPts, strPt, arrPtsa(), arrPtsb(),arrFlrPts(), arrFlrPt(), strObj
arrPts = Rhino.DivideCurve (ArrayOfPoints, k)
Call Rhino.DeleteObject(ArrayOfPoints)
dblConv = 0.0174532925
Dim dblLocX
Dim dblLocY
Dim dblLocZ
Dim dblRadius : dblRadius = dblRadii
Dim intStep : intStep = intLinesa
Dim intOffset : intOffset = intStep/(intStep*4)
For h = 0 To 35 Step intStep
n = 0
For Each arrPt In arrPts
‘Call Rhino.AddPoint (arrPt)
ReDim Preserve arrPtsa(n)
ReDim Preserve arrPtsb(n)
dblLocX = arrPt(0)
dblLocY = arrPt(1)
dblLocZ = arrPt(2)
If n Mod 2 = 0 Then
arrPtsa(n) = (array(cos((h+intOffset)*10*dblConv)*dblRadius+dblLocX, (sin((h+intOffset)*10*dblConv)*dblRadius)*-1+dblLocY, dblLocZ))
arrPtsb(n) = (array(cos((h-intOffset)*10*dblConv)*dblRadius+dblLocX, (sin((h-intOffset)*10*dblConv)*dblRadius)*-1+dblLocY, dblLocZ))
Else
arrPtsa(n) = (array(cos((h+(intStep/2)-intOffset)*10*dblConv)*dblRadius+dblLocX, (sin((h+(intStep/2)-intOffset)*10*dblConv)*dblRadius)*-1+dblLocY, dblLocZ))
arrPtsb(n) = (array(cos((h-(intStep/2)+intOffset)*10*dblConv)*dblRadius+dblLocX, (sin((h-(intStep/2)+intOffset)*10*dblConv)*dblRadius)*-1+dblLocY, dblLocZ))
End If
n=n+1
Next
strObj = Rhino.AddinterpCurve (arrPtsa)
Call  Rhino.ObjectColor (strObj,RGB (0,j,0))
strObj = Rhino.AddinterpCurve (arrPtsb)
Call  Rhino.ObjectColor (strObj,RGB (0,j,0))
‘Call AddPipe(arrPtsa,dblRad,j) : Call AddPipe(arrPtsb,dblRad,j)
Next
End Function

Function Weavinga(ArrayofPoints,ArrayofRadii,intLinesa,intUpper,dblRadii,k)
Dim h, i, j, l, n, m, strObj, strObja, strObjb
Dim arrPtsa(), arrPtsb(), arrFlrPt(), arrFlrPts()
Dim dblLocX
Dim dblLocY
Dim dblLocZ
Dim dblRadius
Dim dblInset : dblInset = 1.1
Dim intStep : intStep = intLinesa*8
Dim dblConv : dblConv = 0.0174532925
Dim dblRot : dblRot = 360/(intStep/2)
Dim intOffset : intOffset = intLinesa/(intLinesa*4)
For h = 0 To 35 Step intLinesa
n = 0
For i=0 To intUpper
ReDim Preserve arrPtsa(n)
ReDim Preserve arrPtsb(n)
dblRadius = ArrayofRadii(n)/3
dblLocX = ArrayofPoints(n)(0)
dblLocY = ArrayofPoints(n)(1)
dblLocZ = ArrayofPoints(n)(2)
If n Mod 2 = 0 Then
arrPtsa(n) = (array(cos((h+intOffset)*10*dblConv)*dblRadius+dblLocX, (sin((h+intOffset)*10*dblConv)*dblRadius)*-1+dblLocY, dblLocZ))
arrPtsb(n) = (array(cos((h-intOffset)*10*dblConv)*dblRadius+dblLocX, (sin((h-intOffset)*10*dblConv)*dblRadius)*-1+dblLocY, dblLocZ))
Else
arrPtsa(n) = (array(cos((h+(intLinesa/2)-intOffset)*10*dblConv)*dblRadius+dblLocX, (sin((h+(intLinesa/2)-intOffset)*10*dblConv)*dblRadius)*-1+dblLocY, dblLocZ))
arrPtsb(n) = (array(cos((h-(intLinesa/2)+intOffset)*10*dblConv)*dblRadius+dblLocX, (sin((h-(intLinesa/2)+intOffset)*10*dblConv)*dblRadius)*-1+dblLocY, dblLocZ))
End If
n=n+1
Next
strObj = Rhino.AddinterpCurve (arrPtsa)
Call Rhino.Objectcolor (strObj,rgb(0,k,0))
strObj = Rhino.AddinterpCurve (arrPtsb)
Call Rhino.Objectcolor (strObj,rgb(0,k,0))
‘Call AddPipe(arrPtsa,dblRad,j) : Call AddPipe(arrPtsb,dblRad,j)
Next
n = 0
For i=0 To intUpper
ReDim Preserve arrFlrPt(n)
If ArrayofRadii(n) > dblRadii Then
dblRadius = ArrayofRadii(n)/3
dblLocX = ArrayofPoints(n)(0)
dblLocY = ArrayofPoints(n)(1)
dblLocZ = ArrayofPoints(n)(2)
If n Mod 2 = 0 Then
m=0
For l = 0 To intStep/2
ReDim Preserve arrFlrPts(m)
If l Mod 2 = 0 Then
arrFlrPts(m) = array(cos(l*(dblRot/2)*dblConv)*dblRadius+dblLocX, (sin(l*(dblRot/2)*dblConv)*dblRadius)*-1+dblLocY, dblLocZ)
Else
arrFlrPts(m) = array(cos(l*(dblRot/2)*dblConv)*(dblRadius/dblInset)+dblLocX, (sin(l*(dblRot/2)*dblConv)*(dblRadius/dblInset))*-1+dblLocY, dblLocZ)
End If
m=m+1
Next
strObja = Rhino.AddinterpCurve (arrFlrPts)
Call Rhino.Objectcolor (strObja,rgb(0,k,0))
m=0
For l = intStep/2 To intStep
ReDim Preserve arrFlrPts(m)
If l Mod 2 = 0 Then
arrFlrPts(m) = array(cos(l*(dblRot/2)*dblConv)*dblRadius+dblLocX, (sin(l*(dblRot/2)*dblConv)*dblRadius)*-1+dblLocY, dblLocZ)
Else
arrFlrPts(m) = array(cos(l*(dblRot/2)*dblConv)*(dblRadius/dblInset)+dblLocX, (sin(l*(dblRot/2)*dblConv)*(dblRadius/dblInset))*-1+dblLocY, dblLocZ)
End If
m=m+1
Next
strObjb = Rhino.AddinterpCurve (arrFlrPts)
Call Rhino.Objectcolor (strObjb,rgb(0,k,0))
‘Call Rhino.Objectcolor (Rhino.AddPlanarSrf (array(strObja,strObjb)),rgb(0,k,0))
Else
m=0
For l = 0 To intStep/2
ReDim Preserve arrFlrPts(m)
If l Mod 2 = 0 Then
arrFlrPts(m) = array(cos(l*(dblRot/2)*dblConv)*(dblRadius/dblInset)+dblLocX, (sin(l*(dblRot/2)*dblConv)*(dblRadius/dblInset))*-1+dblLocY, dblLocZ)
Else
arrFlrPts(m) = array(cos(l*(dblRot/2)*dblConv)*dblRadius+dblLocX, (sin(l*(dblRot/2)*dblConv)*dblRadius)*-1+dblLocY, dblLocZ)
End If
m=m+1
Next
strObja = Rhino.AddinterpCurve (arrFlrPts)
Call Rhino.Objectcolor (strObja,rgb(0,k,0))
m=0
For l = intStep/2 To intStep
ReDim Preserve arrFlrPts(m)
If l Mod 2 = 0 Then
arrFlrPts(m) = array(cos(l*(dblRot/2)*dblConv)*(dblRadius/dblInset)+dblLocX, (sin(l*(dblRot/2)*dblConv)*(dblRadius/dblInset))*-1+dblLocY, dblLocZ)
Else
arrFlrPts(m) = array(cos(l*(dblRot/2)*dblConv)*dblRadius+dblLocX, (sin(l*(dblRot/2)*dblConv)*dblRadius)*-1+dblLocY, dblLocZ)
End If
m=m+1
Next
strObjb = Rhino.AddinterpCurve (arrFlrPts)
Call Rhino.Objectcolor (strObjb,rgb(0,k,0))
‘Call Rhino.Objectcolor (Rhino.AddPlanarSrf (array(strObja,strObjb)),rgb(0,k,0))
End If
End If
n=n+1
Next
‘Call AddPipe(arrPtsa,dblRad,j) : Call AddPipe(arrPtsb,dblRad,j)
End Function

Function AddPipe(arrMovPta,dblRad,k)
Dim strLine, strPipe
strLine = Rhino.AddInterpCurve (arrMovPta)
Call Rhino.SelectObject (strLine)
Call Rhino.Command (“Pipe “&dblRad&” “&dblRad&” enter”)
strPipe = Rhino.LastObject
Call Rhino.ObjectColor (strPipe, rgb(0,k,0))
Call Rhino.Command (“Selnone “)
Call Rhino.DeleteObject (strLine)
End Function

Function random(intLow,intUp)
Randomize
random = (intUp-intLow) * rnd() + intLow
End Function

 

070928_Agritect_v1.1

Option Explicit

‘##########################################################

Call Rhino.EnableRedraw(false)
Call Growth_System()
Call Rhino.EnableRedraw(true)
Sub Growth_System()

 Call Rhino.Print(“########## START SCRIPT ############”)

 ’————— VARIABLES —————–
 Dim i,j,k,n,Plot_yieldL(), YEAR
 Dim iteration : iteration = 0
 Dim Yield_low : Yield_low = 130
 Dim Yield_high  : Yield_high  = 200
 
Dim Plot_x : Plot_x = 2
 Dim Plot_y : Plot_y = 2
 Dim Plot_m : Plot_m = 10

 
Dim nPlots
 nPlots = (Plot_x+1) *( Plot_y+1)
 Dim P(), Ptemp_x(), Ptemp_y()
 Redim Ptemp_x(Plot_x+Plot_y)
 Redim Ptemp_y(Plot_y+Plot_x)
 
 
 ’________________________________ PLANTING ________________

 For i = 0 to Plot_x
   Redim Preserve P(i)
   P(i) = Ptemp_x
  ’———————–
  For j = 0 to Plot_y
   P(i)(j) = Ptemp_y 
  ’———————–
   For k = 0 to 3
     Select Case k
     Case 0
      P(i)(j)(0) = array(i*Plot_m, j*Plot_m, 0)
     Case 1
      P(i)(j)(1) = array(i*Plot_m+Plot_m, j*Plot_m, 0)
     Case 2
      P(i)(j)(2) = array(i*Plot_m, j*Plot_m+Plot_m, 0)
     Case 3
      P(i)(j)(3) = array(i*Plot_m+Plot_m, j*Plot_m+Plot_m, 0)
    End Select
   Next
  ’———————–
   Call Rhino.AddPolyline(array( (P(i)(j)(0)),(P(i)(j)(1)),(P(i)(j)(3)),(P(i)(j)(2)), (P(i)(j)(0)) ) )
  Next
  ’———————–
 Next

 ’_______________________________ GROWTH CYCLE ___________________
 For YEAR = 0 To 17

  Call func_YIELD(Plot_yieldL, Yield_low, Yield_high, nPlots)
  Call func_GROW(Plot_yieldL,  Yield_low, Yield_high, iteration, P, Plot_x, Plot_y)
 
  If iteration < 2 Then
   iteration = iteration + 1
  Else
   iteration = 0   
  End If
 Next
 
 ’__________________________________________________________________
 
End Sub
‘#########################################################
Function func_YIELD(Plot_yieldL, intlow, intup, nPlots)
 Dim i,  Plot_yieldG, n : n=0
 Plot_yieldG = Random(intlow, intup) ‘ *** Field “Average”
 ’——————————————-
 For i = 0 To nPlots
 
  ReDim Preserve Plot_yieldL(n)
  Plot_yieldL(n) = (Random(intlow,intup) ) ‘ *** Local Yield
  n = n+1
  
 Next
 ’——————————————-
End Function
‘########################################################
Function func_GROW(Plot_yieldL, intlow, intup, iteration, P, Plot_x, Plot_y)  
 
 Rhino.Print(“A year has passed… the harvester comes to bring new life.”)

 Dim i,j,k, Growth_MULT, Growth_HEIGHT, Growth_NEW, Check_d, Change_mod(2), Avg_modj(2), n: n=0
 
Dim DIST : DIST = 4
 Growth_HEIGHT = 3

 Dim sLofter_1, sLofter_2, arrLoft()
 Dim Temp_y, Temp_z, Temp_b, Temp_b2, Temp_arr1, Temp_x, Temp_m1, Temp_m2, Change_x, Change_y
 ’———————————————————————————
 For i = 0 to Plot_x
  ’———————–
  For j = 0 to Plot_y
  ’———————–
   For k = 0 to 5
    ’_______________________________________________________
    Select Case k
   ’CORNER 0—————————————————————–
     Case 0 ‘P(i)(j)(0)
      Growth_MULT = Plot_yieldL(n)/((intlow + intup)/2) ‘ *** Percentage compared to average
      Growth_NEW = ( Growth_Height * Growth_MULT )
      Temp_arr1 = P(i)(j)(k)
      ’—
      Temp_y = (P(i)(j)(2)(1) – P(i)(j)(0)(1))/2 + P(i)(j)(0)(1) ‘X
      Temp_x = (P(i)(j)(1)(0) – P(i)(j)(0)(0))/2 + P(i)(j)(0)(0) ‘X
      Temp_z = Growth_Height + P(i)(j)(0)(2)’X
      Temp_m1 = -((Temp_z – P(i)(j)(0)(2))/(Temp_y – P(i)(j)(0)(1)))’X
      Temp_m2 = -((Temp_z – P(i)(j)(0)(2))/(Temp_x – P(i)(j)(0)(0)))
      ’—
      Temp_b = Temp_z – ( Temp_m1 * P(i)(j)(0)(1) ) ‘X
      Temp_b2 = Temp_z – ( Temp_m2 * P(i)(j)(0)(0) ) ‘X
      ’—
      P(i)(j)(0)(1) = ( ( Growth_NEW + P(i)(j)(0)(2) ) – Temp_b ) / Temp_m1 ‘X
      P(i)(j)(0)(0) = ( ( Growth_NEW + P(i)(j)(0)(2) ) – Temp_b2 ) / Temp_m2
      P(i)(j)(0)(2) = Growth_NEW + P(i)(j)(0)(2)
      ’—      
      ’—————————- 
      
      
      If j > 0 Then
       Check_d = Rhino.Distance(P(i)(j)(0), P(i)(j-1)(2))
       If Check_d < DIST Then
        Change_mod(0) = P(i)(j-1)(2)(0) – P(i)(j)(0)(0)
        Change_mod(1) = P(i)(j-1)(2)(1) – P(i)(j)(0)(1)
        Change_mod(2) = P(i)(j-1)(2)(2) – P(i)(j)(0)(2)
        P(i)(j)(0) = P(i)(j-1)(2)
       End If
      Else
       If i > 0 Then
        Check_d = Rhino.Distance(P(i)(j)(0), P(i-1)(j)(1))
        If Check_d < DIST Then
        Change_mod(0) = P(i-1)(j)(2)(0) – P(i)(j)(0)(0)
        Change_mod(1) = P(i-1)(j)(2)(1) – P(i)(j)(0)(1)
        Change_mod(2) = P(i-1)(j)(2)(2) – P(i)(j)(0)(2)         
         P(i)(j)(0) = P(i-1)(j)(1)
        End If  
       End If     
      End If
      
      Change_x = Temp_arr1(0) – P(i)(j)(k)(0)
      Change_y = Temp_arr1(1) – P(i)(j)(k)(1)
      
      Call Rhino.Addline(Temp_arr1, P(i)(j)(k))
             

   ’CORNER 1—————————————————————–
     Case 1 ‘P(i)(j)(1)
      Temp_arr1 = P(i)(j)(k)
      P(i)(j)(1)(0) = P(i)(j)(1)(0) + Change_x
      P(i)(j)(1)(1) = P(i)(j)(1)(1) – Change_y
      P(i)(j)(1)(2) = Growth_NEW + P(i)(j)(1)(2) 
      ’—————————–
      
      If j > 0 Then
       Check_d = Rhino.Distance(P(i)(j)(1), P(i)(j-1)(3))
       If Check_d < Dist Then
        Change_mod(0) =  ( Change_mod(0) + (P(i)(j-1)(3)(0) – P(i)(1)(0)(0)) )/2
        Change_mod(1) =  ( Change_mod(1) + (P(i)(j-1)(3)(1) – P(i)(1)(0)(1)) )/2
        Change_mod(2) =  ( Change_mod(2) + (P(i)(j-1)(3)(2) – P(i)(1)(0)(2)) )/2
        P(i)(j)(1) = P(i)(j-1)(3)
       End If
      End If 
      
      Call Rhino.Addline(Temp_arr1, P(i)(j)(k))     
     

   ’CORNER 2—————————————————————–
     Case 2 ‘P(i)(j)(2)
      Temp_arr1 = P(i)(j)(k)
      P(i)(j)(2)(0) = P(i)(j)(2)(0) – Change_x
      P(i)(j)(2)(1) = P(i)(j)(2)(1) + Change_y
      P(i)(j)(2)(2) = Growth_NEW + P(i)(j)(2)(2) 
      ’—————————-

      If i > 0 Then
       Check_d = Rhino.Distance(P(i)(j)(2), P(i-1)(j)(3))
       If Check_d < DIST Then
        Change_mod(0) =  ( Change_mod(0) + (P(i-1)(j)(3)(0) – P(i)(j)(2)(0)) )/2
        Change_mod(1) =  ( Change_mod(1) + (P(i-1)(j)(3)(1) – P(i)(j)(2)(1)) )/2
        Change_mod(2) =  ( Change_mod(2) + (P(i-1)(j)(3)(2) – P(i)(j)(2)(2)) )/2
        P(i)(j)(2) = P(i-1)(j)(3)
       End If
      End If
      
      Call Rhino.Addline(Temp_arr1, P(i)(j)(k))      
  
          
   ’CORNER 3—————————————————————–
     Case 3 ‘P(i)(j)(3)
      Temp_arr1 = P(i)(j)(k)
      P(i)(j)(3)(0) = P(i)(j)(3)(0) + Change_x
      P(i)(j)(3)(1) = P(i)(j)(3)(1) + Change_y
      P(i)(j)(3)(2) = Growth_NEW + P(i)(j)(3)(2)
      ’—————————-
      If i > 0 Then
       Check_d = Rhino.Distance(P(i)(j)(2), P(i-1)(j)(3))
       If Check_d < DIST Then
        P(i)(j)(2)(0) = P(i)(j)(2)(0) – Change_mod(0)
        P(i)(j)(2)(1) = P(i)(j)(2)(1) – Change_mod(1)
        P(i)(j)(2)(2) = P(i)(j)(2)(2) – Change_mod(2) 
        P(i)(j)(2) = P(i-1)(j)(3)
       End If
      End If
      
      Call Rhino.Addline(Temp_arr1, P(i)(j)(k))
        

      
     ’—————————————————————–
    End Select
     ’____________________________________________________
   Next
   
   
   If iteration = 2 Then
    sLofter_1 = Rhino.Addline(P(i)(j)(0),  P(i)(j)(1))
    sLofter_2 = Rhino.Addline(P(i)(j)(2),  P(i)(j)(3))
    ’arrLoft() = array(sLofter_1, sLofter_2)
    Call Rhino.AddLoftSrf(array(sLofter_1, sLofter_2))
    ’Call Rhino.AddPolyline(array( (P(i)(j)(0)),(P(i)(j)(1)),(P(i)(j)(3)),(P(i)(j)(2)), (P(i)(j)(0)) ) )
   End If
   
   n = n+1
  ’———————–
  Next
  ’———————–
 Next
End Function
‘########################################################
Function random(low, up) 
 Randomize
 random = ((up – low)* Rnd()) + low ‘ *** take the difference of range
End Function

 

 

 

071012_Agritect_v3.1

 07_10-15_script01.jpg 

Option Explicit
Dim gPath_divisions, gPath_r, gPath_height, gYears, gRings, gStart_x, gStart_y
Dim gPLOT_yield, gPLOT_low, gPLOT_high, Ptemp_x, Ptemp_y, gSEED, gCent_r, gCHECK
 Redim Ptemp_x(gYears)
 Redim Ptemp_x(gRings)
 
‘#################################### PARAMETERS #########################################
 gPath_divisions = 20 ’ <– Number of Years for one cycle
 gPath_r = 40   ’ <– Radius of entire structure (base radius)
 gCent_r = 5    ’ <– Radius of center opening
 gRings = 9    ’ <– Number of CONCENTRIC rings from center
 gPath_height = .4   ’ <– HEIGHT OF EACH CHANGE IN ITERATION
 gYEARS = 483    ’ <– NUMBER OF YEARS OF GROWTH
 gPLOT_high = 200   ’ <– Maximum Yield 
 gPLOT_low = 130   ’ <– Minimum Yield

 gSEED = 0    ’ <– Number of ‘towers’
 gCHECK = 100    ’ <– Distance of connection  !!! NOT WORKING YET !!!
‘#########################################################################################

Call Rhino.EnableRedraw(false)
Call Growth(gPath_divisions, gPath_r, gPath_height, gYears, gRings, gPLOT_high, gPLOT_low,gSEED, gCent_r)
Call Rhino.EnableRedraw(true)

‘################################# GROWTH FUNCTION #######################################
Sub Growth(gPath_divisions, gPath_r, gPath_height, gYears, gRings, gPLOT_high, gPLOT_low, gSEED, gCent_r)

 Dim Path(2), Path_theta, gPLOT(), gSEED_start(), lYEAR, Ptemp_x(), Ptemp_y(), Ptemp_z(), i, sLofter_1
 Dim sLofter_2, gPLOT_yield(), gPLOT_avg(), lTemp(2), SURFtemp, Struct_height, lSEED, temp_Distance
 
 Redim Ptemp_z(gYEARS)
 Redim Ptemp_x(gRings)
 Redim Ptemp_y(2)
 Redim gPLOT_avg(gYEARS)
 lYEAR = 0

 ’ —- Establish Array for each Seed —
 For lSEED = 0 to gSEED 
  Redim Preserve gPLOT(lSEED)
  ReDim Preserve gPLOT_yield(lSEED)
  Redim Preserve gPLOT_start(lSEED)
  gPLOT(lSEED) = Ptemp_z
  gPLOT_yield(lSEED) = Ptemp_z

  gPLOT_start(lSEED)= Ptemp_y
 
  gPLOT_start(lSEED)(0) = random(0, 0)
  gPLOT_start(lSEED)(1) = random(0, 0)
 Next
 lSEED = 0
 ’____________________________________________________________________________________
 For Path_theta = 0 to (6.28/gPath_divisions * gYEARS) Step (6.28/gPath_divisions)
 ’Call Rhino.EnableRedraw(false)

 For lSEED = 0 to gSEED
  gPLOT(lSEED)(lYEAR) = Ptemp_x

  gPLOT_yield(lSEED)(lYEAR) = Ptemp_x
  gPLOT_avg(lYEAR) = Random(gPLOT_low, gPLOT_high)

  ’________________________________________________________________________________
  
  For i = 0 to gRings

   gPLOT(lSEED)(lYEAR)(i) = Ptemp_y
   Call func_YIELD(gPLOT_yield,  lYEAR, Ptemp_x, Ptemp_y, i, gPLOT_avg, lSEED)
   
   ’ ——- Z : VERTICAL in relation to YIELD ———————————   
   If lYEAR = 0 Then
    gPLOT(lSEED)(lYEAR)(i)(2) = 0
   Else    
    If lYEAR > gPath_divisions Then
     gPLOT(lSEED)(lYEAR)(i)(2) = ( gPATH_divisions * gPath_height ) * (gPLOT_yield(lSEED)(lYEAR)(i)/((gPLOT_high+gPLOT_low)/2))  + gPLOT(lSEED)(lYEAR-gPath_divisions)(i)(2)
    Else
     gPLOT(lSEED)(lYEAR)(i)(2) = ( (gPLOT_yield(lSEED)(lYEAR)(i)/((gPLOT_high+gPLOT_low)/2)) * gPath_height *gPath_divisions ) – gPath_height * gPath_divisions + gPath_height * lYEAR
    End If    
   End If  
   ’ —————- XY Position ———————————————-
   If lYEAR > gPath_divisions And i < (gRings-1) Then ‘All levels above first
        
     temp_Distance = Rhino.Distance(gPLOT(lSEED)(lYEAR – gPATH_divisions)(gRings), gPLOT(lSEED)(lYEAR – gPATH_divisions)(0))
     gPath_r =  temp_Distance  * (  gPLOT_avg(lYEAR)/((gPLOT_high + gPLOT_low)/2) )
    If i = 0 Then
     gPLOT(lSEED)(lYEAR)(i)(0) = (Cos(Path_theta) * ((gRings – i) /gRings) * gPath_r) + gPLOT_start(lSEED)(0)
     gPLOT(lSEED)(lYEAR)(i)(1) = (Sin(Path_theta) * ((gRings – i) /gRings) * gPath_r) + gPLOT_start(lSEED)(1)
     Call func_NEAR(lYEAR, lSEED, i, gPLOT, gCHECK)

    Else
     temp_Distance = Rhino.Distance( array(gPLOT(lSEED)(lYEAR – gPATH_divisions)(gRings)(0), gPLOT(lSEED)(lYEAR – gPATH_divisions)(gRings)(1), gPLOT(lSEED)(lYEAR)(0)(2)   ), gPLOT(lSEED)(lYEAR)(0))    
     gPLOT(lSEED)(lYEAR)(i)(0) = (Cos(Path_theta) * ((gRings – i) /gRings) * temp_Distance) + gPLOT_start(lSEED)(0)
     gPLOT(lSEED)(lYEAR)(i)(1) = (Sin(Path_theta) * ((gRings – i) /gRings) * temp_Distance) + gPLOT_start(lSEED)(1)
    End If
      
     Else ‘ First level… and inner ring
    If lYEAR > gPath_divisions Then
     If i = gRings Then
      gPLOT(lSEED)(lYEAR)(gRings)(0) =  gPLOT_start(lSEED)(0)
      gPLOT(lSEED)(lYEAR)(gRings)(1) =  gPLOT_start(lSEED)(1)
     Else
      gPLOT(lSEED)(lYEAR)(i)(0) = (Cos(Path_theta) * gCent_r) + gPLOT_start(lSEED)(0)
      gPLOT(lSEED)(lYEAR)(i)(1) = (Sin(Path_theta) * gCent_r) + gPLOT_start(lSEED)(1)
     End If     
    Else
     gPLOT(lSEED)(lYEAR)(i)(0) = (Cos(Path_theta) * ((gRings -i) /gRings) * gPath_r) + gPLOT_start(lSEED)(0)
     gPLOT(lSEED)(lYEAR)(i)(1) = (Sin(Path_theta) * ((gRings -i) /gRings) * gPath_r) + gPLOT_start(lSEED)(1)
    End If
   End If
   ’—————————————————————————-
   If lYEAR > gPATH_divisions + 3 and i = 0 Then
    Call Rhino.AddLine(gPLOT(lSEED)(lYEAR)(i), gPLOT(lSEED)(lYEAR-gPATH_divisions)(i))
   End If
  Next
 Next
  ’Call Rhino.EnableRedraw(true)
  lYEAR = lYEAR + 1  
 Next

  ’_______________________ TEMPORARY SCRIPT: VISUALIZATION ____________________________
 
 Dim Temp_arr, Ptemp_i
 Redim Temp_arr(gSEED)
 Redim Ptemp_i(gRINGS-1)

 For lSEED = 0 to gSEED  
  Redim Preserve Temp_arr(lSEED)
  Temp_arr(lSEED) = Ptemp_i
  For lYEAR = 0 to gYEARS
  For i = 0 to (gRINGS-1)
    Temp_arr(lSEED)(i) = Ptemp_y
    Temp_arr(lSEED)(i)(0) = gPLOT(lSEED)(lYEAR)(i)(0)
    Temp_arr(lSEED)(i)(1) = gPLOT(lSEED)(lYEAR)(i)(1)
    Temp_arr(lSEED)(i)(2) = gPLOT(lSEED)(lYEAR)(i)(2)
  Next
  If lYEAR > 1 Then
   sLofter_2 = sLofter_1
   sLofter_1 = Rhino.AddCurve ( Temp_arr(lSEED), 2)
   Call Rhino.AddLoftSrf( array(sLofter_1, sLofter_2) )
  Else
   sLofter_1 = Rhino.AddCurve ( Temp_arr(lSEED), 2)
  End If
  Next
 Next
End Sub

‘################################## YIELD FUNCTION ######################################

Function func_NEAR(lYEAR, lSEED, i, gPLOT, gCHECK)
 Dim tSEED, tYEAR, tI, tCheck, tCheck2, tP
 Redim tP(2)
 tCheck2 = 1000000
 If lYEAR > 1 Then
  For tSEED = (lSEED+1) to gSEED
   For tYEAR = 0 to lYEAR
    If tSEED > lSEED And tYEAR = lYEAR Then
    
    Else
     tCheck = Rhino.distance(    gPLOT(lSEED)(lYEAR)(0),    gPLOT(tSEED)(tYEAR)(0) )
    End If
    
    If tCheck < gCHECK And tCheck < tCheck2 Then
      tCheck2 = tCheck
      tP(0) = gPLOT(tSEED)(tYEAR)(0)(0)
      tP(1) = gPLOT(tSEED)(tYEAR)(0)(1)
      tP(2) = gPLOT(tSEED)(tYEAR)(0)(2)
    End If
   Next
  Next
  If tCheck2 < 1000000 Then
   gPLOT(lSEED)(lYEAR)(i)(0) = tP(0)
   gPLOT(lSEED)(lYEAR)(i)(1) = tP(1)
   gPLOT(lSEED)(lYEAR)(i)(2) = tP(2)
   Call Rhino.Print( “CONNECTION!” )
  End If
  
 End If
End Function
‘################################## YIELD FUNCTION ######################################
Function func_YIELD(gPLOT_yield, lYEAR, Ptemp_x, Ptemp_y, i, gPLOT_avg, lSEED)
 gPLOT_yield(lSEED)(lYEAR)(i) = ( gPLOT_avg(lYEAR) + Random( 50, -50) ) ‘ *** Local Yield
End Function
‘################################# RANDOM FUNCTION ######################################
Function random(low, up) 
 Randomize
 random = ((up – low)* Rnd()) + low ‘ *** take the difference of range
End Function

071114_Agritect_v4.5

‘########################################################################################################
‘###     AGRITECT version 4.5 : November 14, 2007                                                    
‘###     Copyrighted Matthew R. Pauly, 2007, All rights reserved
‘###     Script developed for (n)certainties studio                                                  
‘########################################################################################################
  Option Explicit
  Call Rhino.Print( ” __________________________ START OF SCRIPT ___________________________ ” )
  Dim gYEAR, gRINGS, gPLOT_low, gPLOT_high, gPath_height, gPath_divisions, gDirection, gPath_r1, gPath_r2
  Dim gCheck
‘######################################## GLOBAL PARAMETERS #############################################
 gYEAR = 600            ’<— Global YEARS the system runs
 gPLOT_high = 200      ’<— Yield, High (in bushels per acre)
 gPLOT_low = 165      ’<— Yield, Low  (in bushels per acre)
 gPath_height = 8         ’<— Start floor to floor height (in meters)
 gPath_r1 = 80      ’<— TEMPORARY seed inner radius(start)
 gPath_r2 = 24     ’<— TEMPORARY seed thickness
 gDirection = 1     ’<— TEMPROARY might change direction depending on seed, Not used
 gPath_divisions = 20  ’<— Number of “chutes” and seeds
 gCheck = gPath_r2 * 3  ’<— Distance to Leech
 ’——FIXED VARIABLES——
 gRINGS = 7       ’<— Number of rings  (3 PLOT, 4 INTERSTICE)
‘########################################################################################################
Call Rhino.EnableRedraw(false)
Call Growth(gYEAR, gRINGS, gPLOT_high, gPLOT_low, gPath_r1, gPath_r2)
Call Rhino.EnableRedraw(true)
‘________________________________________________________________________________________________________
Sub Growth(gYEAR, gRINGS, gPLOT_high, gPLOT_low, gPath_r1, gPath_r2)
 Dim i, temp, lYEAR, gSEED, lSEED, lTheta, lPi, tTheta
 Dim tArr_1(), tArr_2(), tArr_3(2), tYield_1(), tYield_2(), gSEED_start(1), tArr_4(1)
 Dim gPLOT(), gPLOT_lYield(), gPLOT_gYield(), gSEED_chute, gSEED_check(), gSEED_surplus()
 Dim gROBOT_max1, gROBOT_max2, gROBOT_min1, gROBOT_min2
 lTheta = 0
 lPi = Rhino.Pi()
‘———————————————- LOCAL VARIABLES —————————————–
 gSEED = 0′gPath_divisions     ‘<— TEMPORARY Number of seeds, should be lost offspring limit
 gROBOT_max1 = gPath_r1 * 1.1 ’<— Maximum Radius from inner factory
 gROBOT_max2 = gPath_r2 * 2.5 ’<— Maximum width the Robot can expand to
 gROBOT_min1 = gPath_r1 *.95     ‘<— Minimum Radius from inner factory
 gROBOT_min2 = gPath_r2 ‘* .5 ’<— Minimum Width of Robot
‘——————————————————————————————————–
 For lYEAR = 0 to gYEAR
  Redim Preserve gPLOT(lYEAR)
  Redim Preserve gPLOT_lYield(lYEAR)
  Redim Preserve gPLOT_gYield(lYEAR)
  Call func_gYIELD(gPLOT_gYield, gPLOT_low, gPLOT_high, lYEAR)
  If lYEAR < (gPATH_divisions + 1) Then
  lTheta = ((2*lPi)/gPath_divisions ) + lTheta  
  End If
  tTheta = lTheta
  ’———————————————————————————————— 
  For lSEED = 0 to gSEED
   Redim Preserve tArr_1(lSEED)
   Redim Preserve tYield_1(lSEED)
   If lYEAR = 0 Then
    gSEED_chute = 0
    Redim Preserve gSEED_check(lSEED)
    Redim Preserve gSEED_surplus(lSEED)
    gSEED_check(lSEED) = 0
    gSEED_surplus(lSEED) = 0
   End If
   gSEED_check(0) = gPath_divisions + 1
   ’—— Establish each seed’s starting point —–
   If lYEAR < gPath_divisions Then
    If lSEED = 0 Then
     gSEED_start(0) = 0
     gSEED_start(1) = 0
    Else
     gSEED_start(0) = Cos( ((2*lPi)/gPath_divisions)*lSEED )*(  (gPath_r1 + gPath_r2)*2.3 )
     gSEED_start(1) = Sin( ((2*lPi)/gPath_divisions)*lSEED )*(  (gPath_r1 + gPath_r2)*2.3 )
    End If
   Else
    tArr_4(0)=0 
    tArr_4(1)=0 
    For i = 1  to gPath_divisions
     tARR_4(0) = tARR_4(0) + gPLOT(lYEAR-i)(lSEED)(0)(0)
     tARR_4(1) = tARR_4(1) + gPLOT(lYEAR-i)(lSEED)(0)(1)
    Next
    gSEED_start(0) = tARR_4(0)/gPath_divisions
    gSEED_start(1) = tARR_4(1)/gPath_divisions

   End If
   ’————————————————–
   If gSEED_check(lSEED) = 0 And gSEED_chute = lSEED And gPLOT_gYield(lYEAR) > ((gPLOT_high+gPLOT_low)/2) Then
    gSEED_surplus(lSEED) = gSEED_surplus(lSEED) + gPLOT_gYield(lYEAR) – ((gPLOT_high+gPLOT_low)/2)
    If gSEED_surplus(lSEED) > 120 Then ‘<— Critical Mass!!!!
     gSEED_check(lSEED) = 1
    End If
   End If  
   ’__________________________________________________________________________________________  
   Dim temp_Distance3, tHeight
   temp_Distance3 = 0
   
   For i = 0 to gRINGS
    Redim Preserve tArr_2(i)
    Redim Preserve tYield_2(i)
    tArr_2(i) = tArr_3   
    Call func_YIELD(tYield_2, gPLOT_gYield, lYEAR, i)  ’<— Assign local Yield 
   ’—— POSITION ASSIGNMENT ——
   If gSEED_check(lSEED) = 0 Then
    tArr_2(i) = array(gSEED_start(0), gSEED_start(1), 0)  ‘<—- Point assignment for non-triggered seeds
      Else
   ’———————————
    Dim temp_Distance1, temp_Distance2, lPath_r1, lPath_r2
     If lYEAR > gPath_divisions And gSEED_check(lSEED) > gPath_divisions Then ‘ALL LEVELS ABOVE FIRST

     temp_Distance1 = Rhino.Distance(gPLOT(lYEAR – gPATH_divisions)(lSEED)(gRings), gPLOT(lYEAR – gPATH_divisions)(lSEED)(0))
     temp_Distance2 = Rhino.Distance(array( gSEED_start(0), gSEED_start(1), gPLOT(lYEAR – gPATH_divisions)(lSEED)(gRINGS)(2) ), gPLOT(lYEAR – gPATH_divisions)(lSEED)(gRINGS))
     lPath_r2 =  temp_Distance1  * ( (gPLOT_gYield(lYEAR)-gPLOT_low/1.15)/((gPLOT_high + gPLOT_low)/2-gPLOT_low/1.15) )
     lPath_r1 =  temp_Distance2  * ( (gPLOT_gYield(lYEAR))/((gPLOT_high + gPLOT_low)/2) )

     ’—- LIMIT: Robot Radii —
     If lPath_r2 > gROBOT_max2 Then lPath_r2 = gROBOT_max2 End If
     If lPath_r1 > gROBOT_max1 Then lPath_r1 = gROBOT_max1 End If
     If lPath_r2 < gROBOT_min2 Then lPath_r2 = gROBOT_min2 End If
     If lPath_r1 < gROBOT_min1 Then lPath_r1 = gROBOT_min1 End If     
     ’—- Z Location —-

     tArr_2(i)(2) = gPath_height * ((gPLOT_gYield(lYEAR)-gPLOT_low/1.15)/(((gPLOT_high+gPLOT_low)/2)-gPLOT_low/1.15))  + gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2)
     If i = gRINGS Then
      Dim k
      tArr_2(i)(2) = gPath_height * ((gPLOT_gYield(lYEAR-1)-gPLOT_low/1.15)/(((gPLOT_high+gPLOT_low)/2)-gPLOT_low/1.15))  + gPLOT(lYEAR-gPath_divisions)(lSEED)(i)(2)      
      tHeight = tArr_2(i)(2)-tArr_2(0)(2)
      For k = 2 to gRings – 1 Step 2
       tArr_2(k)(2) =  tArr_2(0)(2) – tHeight*k/gRings 
       tArr_2(k-1)(2) = tArr_2(k)(2)    
      Next
     End If           
     ’—- XY Location —-
    If i = 0 Then ‘ Outer Point
     lTheta = (  ((2*lPi)/gPath_divisions )  ) + tTheta 
     ’lTheta = (  ((2*lPi)/gPath_divisions )*(tYield_2(i)/((gPLOT_high+gPLOT_low)/2))  ) + tTheta 
     tArr_2(i)(0) = (Cos(lTheta) *  lPath_r2)+ (Cos(lTheta) * lPath_r1) + gSEED_start(0)
     tArr_2(i)(1) = (Sin(lTheta) *  lPath_r2)+ (Sin(lTheta) * lPath_r1)+ gSEED_start(1)
     Call func_NEAR(gPLOT, tArr_2, lSEED, lYEAR, gCHECK, gPath_height) ‘<——-
    Else
     lTheta = (  ((2*lPi)/gPath_divisions )  ) + tTheta 
     ’lTheta = (  ((2*lPi)/gPath_divisions )*(tYield_2(i)/((gPLOT_high+gPLOT_low)/2))  ) + tTheta 
     If i = 1 Or i = 3 Or i = 5 Or i = 7 Then
      temp_Distance3 = temp_Distance3 + ((lPath_r2 – gPath_r2)/4)
      tArr_2(i)(0) = (Cos(lTheta) *  (lPath_r2- temp_Distance3))+ (Cos(lTheta) * lPath_r1) + gSEED_start(0)
      tArr_2(i)(1) = (Sin(lTheta) *  (lPath_r2- temp_Distance3))+ (Sin(lTheta) * lPath_r1) + gSEED_start(1)
     Else
      temp_Distance3 = temp_Distance3 + (gPath_r2/3)
      tArr_2(i)(0) = (Cos(lTheta) * (lPath_r2- temp_Distance3))+ (Cos(lTheta) * lPath_r1) + gSEED_start(0)
      tArr_2(i)(1) = (Sin(lTheta) *  (lPath_r2- temp_Distance3))+ (Sin(lTheta) * lPath_r1) + gSEED_start(1)    
     End If
    End If
     ‘——————————-   
     Else ‘ FIRST LEVEL
       ’—- Z Location —-
       If lYEAR = 0  Or gSEED_check(lSEED) = 1 Then ‘FIRST YEAR
      tArr_2(i)(2)=0
         Else
      tArr_2(i)(2)=(gPath_height/gPath_divisions) + gPLOT(lYEAR-1)(lSEED)(i)(2)
     End If
     ’—- XY Location —-
     If i = 1 Or i = 3 Or i = 5 Or i = 7 Then
      tArr_2(i)(0) = tArr_2(i-1)(0)
      tArr_2(i)(1) = tArr_2(i-1)(1)
     Else
      tArr_2(i)(0) = ((Cos(lTheta) * ((gRings -i) /gRings) * gPath_r2)) + (Cos(lTheta) * gPath_r1) + gSEED_start(0)
      tArr_2(i)(1) = ((Sin(lTheta) * ((gRings -i) /gRings) * gPath_r2)) + (Sin(lTheta) * gPath_r1) + gSEED_start(1)
     End If
     End If
   End If
    tArr_1(lSEED) = tArr_2     ’<— Assign “Ring Array” to Seed
    tYield_1(lSEED) = tYield_2
   Next
   ’____________________________________________________________________________________________
    If  gSEED_check(lSEED) > 0 Then
     gSEED_check(lSEED) = gSEED_check(lSEED) + 1
    End If
   gPLOT_lYield(lYEAR) = tYield_1   
   gPLOT(lYEAR) = tArr_1      ’<— Assign “Seed Array” to Year 
  Next
  ’————————————————————————————————
    ’—- Adjust to next Chute —-
    If gSEED_chute < gPath_divisions Then
     gSEED_chute = gSEED_chute + 1
    Else
     gSEED_chute = 0
    End If
 Next
‘——————————————————————————————————–
Call func_BUILD2(gPLOT, gRINGS, gPath_divisions, gYEAR)
End Sub
‘________________________________________ FUNCTION : BUILD 2  ____________________________________________
Function func_BUILD2(gPLOT, gRINGS, gPath_divisions, gYEAR)
Dim lYEAR, lSEED, i, n, tARRAY(), tCIRCLES, tPline, j, k, m, p, tStep
Dim arrPlane, sLofter()
arrPlane = Rhino.WorldXYPlane
lSEED = 0
p=0
‘———————– Rings ————————
For m = 1 to 3
p = 0
For n = 0 to gPATH_divisions
 j = 0
 If p = 0 Then
  tStep = gPath_divisions
  Else
  tStep = 0
 End If

 For i = 0 to (gYEAR-tStep) Step gPATH_divisions
  If i+n <= gYEAR Then
   Redim Preserve tARRAY(j)
   tARRAY(j) = gPLOT(i+n)(lSEED)(m*2-1)
   j = j + 1
  End If
  k = i
 Next
 For i = k to 0 Step -gPATH_divisions
  If i+n <= gYEAR Then
   Redim Preserve tARRAY(j)
   tARRAY(j) = gPLOT(i+n)(lSEED)(m*2)
   j = j + 1
  End If
 Next
 Redim Preserve tARRAY(j)
 tARRAY(j) = tARRAY(0)
 
 Redim Preserve sLofter(p)
 sLofter(p) = Rhino.AddPolyline (tARRAY)
 p = p+1
Next
 Call Rhino.AddLoftSrf(sLofter) 
Next
End Function
‘________________________________________ FUNCTION : lYIELD ____________________________________________
Function func_YIELD(Yield, gPLOT_avg, lYEAR,  i)
 Yield(i) = ( gPLOT_avg(lYEAR) + Random( -0, 0) ) ‘ <— Local Yield
End Function
‘________________________________________ FUNCTION : gYIELD ____________________________________________
Function func_gYIELD(gPLOT_avg, gPLOT_low, gPLOT_high, lYEAR)
 gPLOT_avg(lYEAR) =  Random(gPLOT_low, gPLOT_high)
End Function
‘________________________________________ FUNCTION : RANDOM ____________________________________________
Function Random(low, up) 
 Randomize
 random = ((up – low)* Rnd()) + low ‘ *** take the difference of range
End Function
‘________________________________________ FUNCTION : NEAREST____________________________________________
Function func_NEAR(lPLOT, tPlot, lSEED, lYEAR, gCHECK, gPath_height)
 Dim tYEAR, tSEED, dHOLD, dCHECK_z, dCHECK_xy, holdSEED, holdYEAR, tPoint
 dHOLD = 10000000
 
 For tYEAR = 0 to (uBound(lPLOT)-1)
  For tSEED = 0 to uBound( lPLOT(tYEAR) )
   If tSEED <> lSEED  And lPLOT(tYEAR)(tSEED)(0)(2) > tPLOT(0)(2)Then
    dCHECK_xy = Rhino.Distance( array(lPLOT(tYEAR)(tSEED)(0)(0), lPLOT(tYEAR)(tSEED)(0)(1), 0), array(tPLOT(0)(0), tPLOT(0)(1), 0) )
    dCHECK_z = abs( lPLOT(tYEAR)(tSEED)(0)(2) – tPLOT(0)(2) )
    
    If dCHECK_xy > 0 And dCHECK_xy < gCHECK And dCHECK_xy < dHOLD And dCHECK_z < (gPath_height * .5) Then
     dHOLD = dCHECK_xy
     tPoint = lPLOT(tYEAR)(tSEED)(0)
     holdSEED = tSEED
     holdYEAR = tYEAR   
    End If
   End If
  Next
 Next
 ’—–
 If dHOLD < 10000000 Then
  If dHOLD < (gCHECK * .33) Then
  ’ tPLOT(0) = tPoint
  Else
  ’ Call Rhino.AddCylinder(tPoint, tPLOT(0), 1 )
  End If

 End If
End Function

 

------------------------------------

Pages of Code / RVB / Back