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
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.