Week 2

——————-Week 2 Assignment—————————-

1. Required: Detail the specific material and size of your cell.

2. Required: Prepare your first material test with your actual material.

3. Optional: Modify lamp script and post results.

———————–Week 2 Class —————————-

This will review the process of making a lamp from a distance based attractor. The material will be 1/4″ plexi-glass that will be laser cut.

———————Step 1—————————-

Option Explicit

‘Script written by mark.bearak

‘Script copyrighted by dtls.Architecture

‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Main()

Sub Main()

Dim arrPt

arrPt = array(0,0,120)

Call Rhino.addPoint (arrPt)

End Sub

———————Step 2—————————-

__Step

Call Main()

Sub Main()

Dim arrPt, i, j

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPt = array(i,j,120)

Call Rhino.addPoint (arrPt)

Next

Next

End Sub

———————Step 3—————————-

__Polar

Call Delete()

Call Main()

Sub Main()

Dim arrPt, i, j, arrNewPt

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPt = array(i,j,120)

arrNewPt = Rhino.Polar (arrPt, 90, 4)

Call Rhino.addPoint (arrPt)

Call Rhino.AddPoint (arrNewPt)

Call Rhino.AddLine (arrPt, arrNewPt)

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 4—————————-

__360 degree polar equations

Call Delete()

Call Main()

Sub Main()

Dim arrPt, i, j, arrNewPta, arrNewPtb, arrNewPtc, arrNewPtd

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPt = array(i,j,120)

arrNewPta = Rhino.Polar (arrPt, -180, 4)

arrNewPtb = Rhino.Polar (arrPt, -90, 4)

arrNewPtc = Rhino.Polar (arrPt, 0, 4)

arrNewPtd = Rhino.Polar (arrPt, 90, 4)

Call Rhino.AddLine (arrPt, arrNewPta)

Call Rhino.AddLine (arrPt, arrNewPtb)

Call Rhino.AddLine (arrPt, arrNewPtc)

Call Rhino.AddLine (arrPt, arrNewPtd)

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 5—————————-

__Looping the polar equation

Call Delete()

Call Main()

Sub Main()

Dim arrPt, i, j, k, arrNewPt

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPt = array(i,j,120)

For k = -180 To 90 Step 90

arrNewPt = Rhino.Polar (arrPt, k, 4)

Call Rhino.AddLine (arrPt, arrNewPt)

Next

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 6—————————-

_Lock command

_Get Point

_Distance command

_Create a relationship with the distance

Call Delete()

Call Main()

Sub Main()

Dim arrLoc : arrLoc = Rhino.GetPoint (“select your locator”)

Dim arrPt, i, j, k, arrNewPt, dblDist

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPt = array(i,j,120)

dblDist = Rhino.Distance (arrLoc, arrPt)

For k = -180 To 90 Step 90

arrNewPt = Rhino.Polar (arrPt, k, dblDist)

Call Rhino.AddLine (arrPt, arrNewPt)

Next

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 7—————————-

_If/Then additions

_Placing a limit on the min/max size of a lamp

Call Delete()

Call Main()

Sub Main()

Dim arrLoc : arrLoc = Rhino.GetPoint (“select your locator”)

Dim arrPt, i, j, k, arrNewPt, dblDist

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPt = array(i,j,120)

dblDist = Rhino.Distance (arrLoc, arrPt)

dblDist = dblDist/12

If dblDist > 9 Then

dblDist = 9

End If

If dblDist < 2 Then

dblDist = 2

End If

For k = -180 To 90 Step 90

arrNewPt = Rhino.Polar (arrPt, k, dblDist)

Call Rhino.AddLine (arrPt, arrNewPt)

Next

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 8—————————-

__Using the distance for multiple variables

Call Delete()

Call Main()

Sub Main()

Dim arrLoc : arrLoc = Rhino.GetPoint (“select your locator”)

Dim arrPt, i, j, k, dblDist, arrNewPta, arrNewPtb, arrNewPtc

For i = 0 To 72 Step 24

For j = 0 To 168 Step 24

arrPt = array(i,j,120)

dblDist = Rhino.Distance (arrLoc, arrPt)

dblDist = dblDist/12

If dblDist > 8.5 Then dblDist = 8.5

If dblDist < 2 Then dblDist = 2

For k = -180 To 90 Step 90

arrNewPta = Rhino.Polar (arrPt, k, dblDist)

arrNewPtb = array(arrNewPta(0),arrNewPta(1),arrNewPta(2)-(dblDist*4))

arrNewPtc = array(arrPt(0),arrPt(1),arrPt(2)-(dblDist*4))

Call Rhino.AddLine (arrPt, arrNewPta)

Call Rhino.AddLine (arrNewPta,arrNewPtb)

Call Rhino.AddLine (arrNewPtb,arrNewPtc)

Next

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 9—————————-

_AddCurve command

_Join Command

_Using a counter

Call Delete()

Call Main()

Sub Main()

Dim arrLoc : arrLoc = Rhino.GetPoint (“select your locator”)

Dim arrPt, i, j, k, dblDist, arrNewPta, arrNewPtb, arrNewPtc, strCrva(), strCrvb(), counter

For i = 0 To 72 Step 24

For j = 0 To 168 Step 24

arrPt = array(i,j,120)

dblDist = Rhino.Distance (arrLoc, arrPt)

dblDist = dblDist/12

If dblDist > 8.5 Then dblDist = 8.5

If dblDist < 2 Then dblDist = 2

counter = 0

For k = -180 To 90 Step 90

ReDim Preserve strCrva(counter)

ReDim Preserve strCrvb(counter)

arrNewPta = Rhino.Polar (arrPt, k, dblDist)

arrNewPtb = array(arrNewPta(0),arrNewPta(1),arrNewPta(2)-(dblDist*4))

arrNewPtc = array(arrPt(0),arrPt(1),arrPt(2)-(dblDist*4))

strCrva(counter) = Rhino.AddLine (arrPt, arrNewPta)

strCrvb(counter) = Rhino.AddCurve (array(arrNewPta,arrNewPtb,arrNewPtc))

counter = counter+1

Next

Call Rhino.JoinCurves (array(strCrva(0),strCrvb(0),strCrva(2),strCrvb(2)),True)

Call Rhino.JoinCurves (array(strCrva(1),strCrvb(1),strCrva(3),strCrvb(3)),True)

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 10—————————-

_AddPlanarSrf Command

Call Delete()

Call Main()

Sub Main()

Dim arrLoc : arrLoc = Rhino.GetPoint (“select your locator”)

Dim arrPt, i, j, k, dblDist, arrNewPta, arrNewPtb, arrNewPtc, strCrva(), strCrvb(), counter, arrFinalCrvsa, arrFinalCrvsb

For i = 0 To 72 Step 24

For j = 0 To 168 Step 24

arrPt = array(i,j,120)

dblDist = Rhino.Distance (arrLoc, arrPt)

dblDist = dblDist/12

If dblDist > 8.5 Then dblDist = 8.5

If dblDist < 2 Then dblDist = 2

counter = 0

For k = -180 To 90 Step 90

ReDim Preserve strCrva(counter)

ReDim Preserve strCrvb(counter)

arrNewPta = Rhino.Polar (arrPt, k, dblDist)

arrNewPtb = array(arrNewPta(0),arrNewPta(1),arrNewPta(2)-(dblDist*4))

arrNewPtc = array(arrPt(0),arrPt(1),arrPt(2)-(dblDist*4))

strCrva(counter) = Rhino.AddLine (arrPt, arrNewPta)

strCrvb(counter) = Rhino.AddCurve (array(arrNewPta,arrNewPtb,arrNewPtc))

counter = counter+1

Next

arrFinalCrvsa = Rhino.JoinCurves (array(strCrva(0),strCrvb(0),strCrva(2),strCrvb(2)),True)

arrFinalCrvsb = Rhino.JoinCurves (array(strCrva(1),strCrvb(1),strCrva(3),strCrvb(3)),True)

Call Rhino.AddPlanarSrf (arrFinalCrvsa)

Call Rhino.AddPlanarSrf (arrFinalCrvsb)

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 11—————————-

_Command Line Entry

_UnrollSrf e=n

Option Explicit
‘Script written by mark.bearak
‘Script copyrighted by dtls.Architecture
‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()
Call Main()

Sub Main()
Dim arrLoc : arrLoc = Rhino.GetPoint (“select your locator”)
Dim arrPt, i, j, k, dblDist, arrNewPta, arrNewPtb, arrNewPtc, strCrva(), strCrvb(), counter, arrFinalCrvsa, arrFinalCrvsb
Dim strSrfa, arrSrfsa, strSrfb, arrSrfsb
For i = 0 To 72 Step 24
For j = 0 To 168 Step 24
arrPt = array(i,j,120)
dblDist = Rhino.Distance (arrLoc, arrPt)
dblDist = dblDist/12
If dblDist > 8.5 Then dblDist = 8.5
If dblDist < 2 Then dblDist = 2
counter = 0
For k = -180 To 90 Step 90
ReDim Preserve strCrva(counter)
ReDim Preserve strCrvb(counter)
arrNewPta = Rhino.Polar (arrPt, k, dblDist)
arrNewPtb = array(arrNewPta(0),arrNewPta(1),arrNewPta(2)-(dblDist*4))
arrNewPtc = array(arrPt(0),arrPt(1),arrPt(2)-(dblDist*4))
strCrva(counter) = Rhino.AddLine (arrPt, arrNewPta)
strCrvb(counter) = Rhino.AddCurve (array(arrNewPta,arrNewPtb,arrNewPtc))
counter = counter+1
Next
arrFinalCrvsa = Rhino.JoinCurves (array(strCrva(0),strCrvb(0),strCrva(2),strCrvb(2)),True)
arrFinalCrvsb = Rhino.JoinCurves (array(strCrva(1),strCrvb(1),strCrva(3),strCrvb(3)),True)
arrSrfsa = Rhino.AddPlanarSrf (arrFinalCrvsa)
For Each strSrfa In arrSrfsa
Call Rhino.SelectObject (strSrfa)
Call Rhino.Command (“unrollsrf e=n enter”)
Call Rhino.UnselectAllObjects
Next
arrSrfsb = Rhino.AddPlanarSrf (arrFinalCrvsb)
For Each strSrfb In arrSrfsb
Call Rhino.SelectObject (strSrfb)
Call Rhino.Command (“unrollsrf e=n enter”)
Call Rhino.UnselectAllObjects
Next
Next
Next
End Sub

Sub Delete()
Call Rhino.Command (“selall “)
Call Rhino.Command (“delete “)
End Sub

———————Step 12—————————-

_Isolating protocol

_Functions

_DuplicateSurfaceBorder

_BoundingBox

_Extracting mathematics from the bounding box

Option Explicit
‘Script written by mark.bearak
‘Script copyrighted by dtls.Architecture
‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()
Call Main()

Sub Main()
Dim arrLoc : arrLoc = Rhino.GetPoint (“select your locator”)
Dim arrPt, i, j, k, dblDist, arrNewPta, arrNewPtb, arrNewPtc, strCrva(), strCrvb(), counter, arrFinalCrvsa, arrFinalCrvsb
Dim strSrfa, arrSrfsa, strSrfb, arrSrfsb, strUnrollSrf
For i = 0 To 72 Step 24
For j = 0 To 168 Step 24
arrPt = array(i,j,120)
dblDist = Rhino.Distance (arrLoc, arrPt)
dblDist = dblDist/12
If dblDist > 8.5 Then dblDist = 8.5
If dblDist < 2 Then dblDist = 2
counter = 0
For k = -180 To 90 Step 90
ReDim Preserve strCrva(counter)
ReDim Preserve strCrvb(counter)
arrNewPta = Rhino.Polar (arrPt, k, dblDist)
arrNewPtb = array(arrNewPta(0),arrNewPta(1),arrNewPta(2)-(dblDist*4))
arrNewPtc = array(arrPt(0),arrPt(1),arrPt(2)-(dblDist*4))
strCrva(counter) = Rhino.AddLine (arrPt, arrNewPta)
strCrvb(counter) = Rhino.AddCurve (array(arrNewPta,arrNewPtb,arrNewPtc))
counter = counter+1
Next
arrFinalCrvsa = Rhino.JoinCurves (array(strCrva(0),strCrvb(0),strCrva(2),strCrvb(2)),True)
arrFinalCrvsb = Rhino.JoinCurves (array(strCrva(1),strCrvb(1),strCrva(3),strCrvb(3)),True)
arrSrfsa = Rhino.AddPlanarSrf (arrFinalCrvsa)
For Each strSrfa In arrSrfsa
Call Rhino.SelectObject (strSrfa)
Call Rhino.Command (“unrollsrf e=n enter”)
Call Rhino.UnselectAllObjects
strUnrollSrf = rhino.FirstObject
Call Unroll(strUnrollSrf)
Next
arrSrfsb = Rhino.AddPlanarSrf (arrFinalCrvsb)
For Each strSrfb In arrSrfsb
Call Rhino.SelectObject (strSrfb)
Call Rhino.Command (“unrollsrf e=n enter”)
Call Rhino.UnselectAllObjects
Next
Next
Next
End Sub

Sub Delete()
Call Rhino.Command (“selall “)
Call Rhino.Command (“delete “)
End Sub

Function Unroll(strSrf)
Dim arrBoundingBox
arrBoundingBox = Rhino.BoundingBox (strSrf)
Call Rhino.DuplicateSurfaceBorder (strSrf)
Call Rhino.AddLine (array(arrBoundingBox(0)(0),(arrBoundingBox(0)(1)+arrBoundingBox(3)(1))/2),array((arrBoundingBox(0)(0)+arrBoundingBox(1)(0))/2,(arrBoundingBox(1)(1)+arrBoundingBox(2)(1))/2))
End Function

———————Step 13—————————-

_Copying functions

-Adding information into the function

Option Explicit
‘Script written by mark.bearak
‘Script copyrighted by dtls.Architecture
‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()
Call Main()

Sub Main()
Dim arrLoc : arrLoc = Rhino.GetPoint (“select your locator”)
Dim arrPt, i, j, k, dblDist, arrNewPta, arrNewPtb, arrNewPtc, strCrva(), strCrvb(), counter, arrFinalCrvsa, arrFinalCrvsb
Dim strSrfa, arrSrfsa, strSrfb, arrSrfsb, strUnrollSrf
For i = 0 To 72 Step 24
For j = 0 To 168 Step 24
arrPt = array(i,j,120)
dblDist = Rhino.Distance (arrLoc, arrPt)
dblDist = dblDist/12
If dblDist > 8.5 Then dblDist = 8.5
If dblDist < 2 Then dblDist = 2
counter = 0
For k = -180 To 90 Step 90
ReDim Preserve strCrva(counter)
ReDim Preserve strCrvb(counter)
arrNewPta = Rhino.Polar (arrPt, k, dblDist)
arrNewPtb = array(arrNewPta(0),arrNewPta(1),arrNewPta(2)-(dblDist*4))
arrNewPtc = array(arrPt(0),arrPt(1),arrPt(2)-(dblDist*4))
strCrva(counter) = Rhino.AddLine (arrPt, arrNewPta)
strCrvb(counter) = Rhino.AddCurve (array(arrNewPta,arrNewPtb,arrNewPtc))
counter = counter+1
Next
arrFinalCrvsa = Rhino.JoinCurves (array(strCrva(0),strCrvb(0),strCrva(2),strCrvb(2)),True)
arrFinalCrvsb = Rhino.JoinCurves (array(strCrva(1),strCrvb(1),strCrva(3),strCrvb(3)),True)
arrSrfsa = Rhino.AddPlanarSrf (arrFinalCrvsa)
For Each strSrfa In arrSrfsa
Call Rhino.SelectObject (strSrfa)
Call Rhino.Command (“unrollsrf e=n enter”)
Call Rhino.UnselectAllObjects
strUnrollSrf = rhino.FirstObject
Call Unrolla(strUnrollSrf, array(i*2,j*2))
Next
arrSrfsb = Rhino.AddPlanarSrf (arrFinalCrvsb)
For Each strSrfb In arrSrfsb
Call Rhino.SelectObject (strSrfb)
Call Rhino.Command (“unrollsrf e=n enter”)
Call Rhino.UnselectAllObjects
strUnrollSrf = rhino.FirstObject
Call Unrollb(strUnrollSrf, array(i*2,(j*2)-17))
Next
Next
Next
End Sub

Sub Delete()
Call Rhino.Command (“selall “)
Call Rhino.Command (“delete “)
End Sub

Function Unrolla(strSrf,arrLoc)
Dim arrBoundingBox, strCrv, arrCrvs
arrBoundingBox = Rhino.BoundingBox (strSrf)
arrCrvs = Rhino.DuplicateSurfaceBorder (strSrf)
Call Rhino.DeleteObject (strSrf)
strCrv = Rhino.AddLine (array(arrBoundingBox(0)(0),(arrBoundingBox(0)(1)+arrBoundingBox(3)(1))/2),array((arrBoundingBox(0)(0)+arrBoundingBox(1)(0))/2,(arrBoundingBox(1)(1)+arrBoundingBox(2)(1))/2))
Call Rhino.MoveObject (strCrv, array(0,0),arrLoc)
Call Rhino.MoveObjects (arrCrvs, array(0,0),arrLoc)
End Function

Function Unrollb(strSrf,arrLoc)
Dim arrBoundingBox, strCrv, arrCrvs
arrBoundingBox = Rhino.BoundingBox (strSrf)
arrCrvs = Rhino.DuplicateSurfaceBorder (strSrf)
Call Rhino.DeleteObject (strSrf)
strCrv = Rhino.AddLine (array(arrBoundingBox(1)(0),(arrBoundingBox(0)(1)+arrBoundingBox(3)(1))/2),array((arrBoundingBox(0)(0)+arrBoundingBox(1)(0))/2,(arrBoundingBox(1)(1)+arrBoundingBox(2)(1))/2))
Call Rhino.MoveObject (strCrv, array(0,0),arrLoc)
Call Rhino.MoveObjects (arrCrvs, array(0,0),arrLoc)
End Function

———————Step 14—————————-

_Applying material thickness

_CurveStartPoint/CurveEndPoint

Option Explicit
‘Script written by mark.bearak
‘Script copyrighted by dtls.Architecture
‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()
Call Main()

Sub Main()
Dim arrLoc : arrLoc = Rhino.GetPoint (“select your locator”)
Dim dblWidth : dblWidth = Rhino.GetReal (“how wide is your material”,.125)
Dim arrPt, i, j, k, dblDist, arrNewPta, arrNewPtb, arrNewPtc, strCrva(), strCrvb(), counter, arrFinalCrvsa, arrFinalCrvsb
Dim strSrfa, arrSrfsa, strSrfb, arrSrfsb, strUnrollSrf
For i = 0 To 72 Step 24
For j = 0 To 168 Step 24
arrPt = array(i,j,120)
dblDist = Rhino.Distance (arrLoc, arrPt)
dblDist = dblDist/12
If dblDist > 8.5 Then dblDist = 8.5
If dblDist < 2 Then dblDist = 2
counter = 0
For k = -180 To 90 Step 90
ReDim Preserve strCrva(counter)
ReDim Preserve strCrvb(counter)
arrNewPta = Rhino.Polar (arrPt, k, dblDist)
arrNewPtb = array(arrNewPta(0),arrNewPta(1),arrNewPta(2)-(dblDist*4))
arrNewPtc = array(arrPt(0),arrPt(1),arrPt(2)-(dblDist*4))
strCrva(counter) = Rhino.AddLine (arrPt, arrNewPta)
strCrvb(counter) = Rhino.AddCurve (array(arrNewPta,arrNewPtb,arrNewPtc))
counter = counter+1
Next
arrFinalCrvsa = Rhino.JoinCurves (array(strCrva(0),strCrvb(0),strCrva(2),strCrvb(2)),True)
arrFinalCrvsb = Rhino.JoinCurves (array(strCrva(1),strCrvb(1),strCrva(3),strCrvb(3)),True)
arrSrfsa = Rhino.AddPlanarSrf (arrFinalCrvsa)
For Each strSrfa In arrSrfsa
Call Rhino.SelectObject (strSrfa)
Call Rhino.Command (“unrollsrf e=n enter”)
Call Rhino.UnselectAllObjects
strUnrollSrf = rhino.FirstObject
Call Unrolla(strUnrollSrf, array(i*2,j*2),dblWidth)
Next
arrSrfsb = Rhino.AddPlanarSrf (arrFinalCrvsb)
For Each strSrfb In arrSrfsb
Call Rhino.SelectObject (strSrfb)
Call Rhino.Command (“unrollsrf e=n enter”)
Call Rhino.UnselectAllObjects
strUnrollSrf = rhino.FirstObject
Call Unrollb(strUnrollSrf, array(i*2,(j*2)-17),dblWidth)
Next
Next
Next
End Sub

Sub Delete()
Call Rhino.Command (“selall “)
Call Rhino.Command (“delete “)
End Sub

Function Unrolla(strSrf,arrLoc,dblWidth)
Dim arrBoundingBox, strCrv, strCrvb, arrCrvs
arrBoundingBox = Rhino.BoundingBox (strSrf)
arrCrvs = Rhino.DuplicateSurfaceBorder (strSrf)
Call Rhino.DeleteObject (strSrf)
strCrv = Rhino.AddLine (array(arrBoundingBox(0)(0),(arrBoundingBox(0)(1)+arrBoundingBox(3)(1))/2),array((arrBoundingBox(0)(0)+arrBoundingBox(1)(0))/2,(arrBoundingBox(1)(1)+arrBoundingBox(2)(1))/2))
Call Rhino.MoveObject (strCrv, array(0,0),array(arrLoc(0),arrLoc(1)+dblWidth/2))
strCrvb = Rhino.CopyObject (strCrv, array(0,0),array(0,0-(dblWidth)))
Call Rhino.MoveObjects (arrCrvs, array(0,0),arrLoc)
Call Rhino.addLine (rhino.CurveStartPoint (strCrv),rhino.CurveStartPoint (strCrvb))
Call Rhino.addLine (rhino.CurveEndPoint (strCrv),rhino.CurveEndPoint (strCrvb))
End Function

Function Unrollb(strSrf,arrLoc,dblWidth)
Dim arrBoundingBox, strCrv, strCrvb, arrCrvs
arrBoundingBox = Rhino.BoundingBox (strSrf)
arrCrvs = Rhino.DuplicateSurfaceBorder (strSrf)
Call Rhino.DeleteObject (strSrf)
strCrv = Rhino.AddLine (array(arrBoundingBox(1)(0),(arrBoundingBox(0)(1)+arrBoundingBox(3)(1))/2),array((arrBoundingBox(0)(0)+arrBoundingBox(1)(0))/2,(arrBoundingBox(1)(1)+arrBoundingBox(2)(1))/2))
Call Rhino.MoveObject (strCrv, array(0,0),array(arrLoc(0),arrLoc(1)+dblWidth/2))
strCrvb = Rhino.CopyObject (strCrv, array(0,0),array(0,0-(dblWidth)))
Call Rhino.MoveObjects (arrCrvs, array(0,0),arrLoc)
Call Rhino.addLine (rhino.CurveStartPoint (strCrv),rhino.CurveStartPoint (strCrvb))
Call Rhino.addLine (rhino.CurveEndPoint (strCrv),rhino.CurveEndPoint (strCrvb))
End Function

———————Step 15—————————-

_Adding Text

Option Explicit
‘Script written by mark.bearak
‘Script copyrighted by dtls.Architecture
‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()
Call Main()

Sub Main()
Dim arrLoc : arrLoc = Rhino.GetPoint (“select your locator”)
Dim dblWidth : dblWidth = Rhino.GetReal (“how wide is your material”,.125)
Dim arrPt, i, j, k, dblDist, arrNewPta, arrNewPtb, arrNewPtc, strCrva(), strCrvb(), counter, arrFinalCrvsa, arrFinalCrvsb
Dim strSrfa, arrSrfsa, strSrfb, arrSrfsb, strUnrollSrf
For i = 0 To 72 Step 24
For j = 0 To 168 Step 24
arrPt = array(i,j,120)
dblDist = Rhino.Distance (arrLoc, arrPt)
dblDist = dblDist/12
If dblDist > 8.5 Then dblDist = 8.5
If dblDist < 2 Then dblDist = 2
counter = 0
For k = -180 To 90 Step 90
ReDim Preserve strCrva(counter)
ReDim Preserve strCrvb(counter)
arrNewPta = Rhino.Polar (arrPt, k, dblDist)
arrNewPtb = array(arrNewPta(0),arrNewPta(1),arrNewPta(2)-(dblDist*4))
arrNewPtc = array(arrPt(0),arrPt(1),arrPt(2)-(dblDist*4))
strCrva(counter) = Rhino.AddLine (arrPt, arrNewPta)
strCrvb(counter) = Rhino.AddCurve (array(arrNewPta,arrNewPtb,arrNewPtc))
counter = counter+1
Next
arrFinalCrvsa = Rhino.JoinCurves (array(strCrva(0),strCrvb(0),strCrva(2),strCrvb(2)),True)
arrFinalCrvsb = Rhino.JoinCurves (array(strCrva(1),strCrvb(1),strCrva(3),strCrvb(3)),True)
arrSrfsa = Rhino.AddPlanarSrf (arrFinalCrvsa)
For Each strSrfa In arrSrfsa
Call Rhino.SelectObject (strSrfa)
Call Rhino.Command (“unrollsrf e=n enter”)
Call Rhino.UnselectAllObjects
strUnrollSrf = rhino.FirstObject
Call Unrolla(strUnrollSrf, array(i*2,j*2),dblWidth)
Next
arrSrfsb = Rhino.AddPlanarSrf (arrFinalCrvsb)
For Each strSrfb In arrSrfsb
Call Rhino.SelectObject (strSrfb)
Call Rhino.Command (“unrollsrf e=n enter”)
Call Rhino.UnselectAllObjects
strUnrollSrf = rhino.FirstObject
Call Unrollb(strUnrollSrf, array(i*2,(j*2)-17),dblWidth)
Next
Next
Next
End Sub

Sub Delete()
Call Rhino.Command (“selall “)
Call Rhino.Command (“delete “)
End Sub

Function Unrolla(strSrf,arrLoc,dblWidth)
Dim arrBoundingBox, strCrv, strCrvb, arrCrvs
arrBoundingBox = Rhino.BoundingBox (strSrf)
arrCrvs = Rhino.DuplicateSurfaceBorder (strSrf)
Call Rhino.DeleteObject (strSrf)
strCrv = Rhino.AddLine (array(arrBoundingBox(0)(0),(arrBoundingBox(0)(1)+arrBoundingBox(3)(1))/2),array((arrBoundingBox(0)(0)+arrBoundingBox(1)(0))/2,(arrBoundingBox(1)(1)+arrBoundingBox(2)(1))/2))
Call Rhino.MoveObject (strCrv, array(0,0),array(arrLoc(0),arrLoc(1)+dblWidth/2))
strCrvb = Rhino.CopyObject (strCrv, array(0,0),array(0,0-(dblWidth)))
Call Rhino.MoveObjects (arrCrvs, array(0,0),arrLoc)
Call Rhino.addLine (rhino.CurveStartPoint (strCrv),rhino.CurveStartPoint (strCrvb))
Call Rhino.addLine (rhino.CurveEndPoint (strCrv),rhino.CurveEndPoint (strCrvb))
Call Rhino.AddText (arrLoc(0)/48 & arrLoc(1)/48, array(arrLoc(0),(arrLoc(1))-25,0),6)
End Function

Function Unrollb(strSrf,arrLoc,dblWidth)
Dim arrBoundingBox, strCrv, strCrvb, arrCrvs
arrBoundingBox = Rhino.BoundingBox (strSrf)
arrCrvs = Rhino.DuplicateSurfaceBorder (strSrf)
Call Rhino.DeleteObject (strSrf)
strCrv = Rhino.AddLine (array(arrBoundingBox(1)(0),(arrBoundingBox(0)(1)+arrBoundingBox(3)(1))/2),array((arrBoundingBox(0)(0)+arrBoundingBox(1)(0))/2,(arrBoundingBox(1)(1)+arrBoundingBox(2)(1))/2))
Call Rhino.MoveObject (strCrv, array(0,0),array(arrLoc(0),arrLoc(1)+dblWidth/2))
strCrvb = Rhino.CopyObject (strCrv, array(0,0),array(0,0-(dblWidth)))
Call Rhino.MoveObjects (arrCrvs, array(0,0),arrLoc)
Call Rhino.addLine (rhino.CurveStartPoint (strCrv),rhino.CurveStartPoint (strCrvb))
Call Rhino.addLine (rhino.CurveEndPoint (strCrv),rhino.CurveEndPoint (strCrvb))
End Function

——————-Week 2 Pre-Tutorial Session——————–

This session will introduce you to distance based parametric models. Please review the steps, if you can check off all of the topics then you can skip this weeks tutorial. See you on Wednesday at 8:00 in Avery 114.

———————Step 1—————————-

_Multiple subs – two separate protocols on the same script

_Command line entry – rhino.command (“xxx”)

Option Explicit

‘Script written by mark.bearak

‘Script copyrighted by dtls.Architecture

‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()

Call Main()

Sub Main()

Dim arrPt

arrPt = array(0,0,120)

Call Rhino.addPoint (arrPt)

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 2—————————-

_Multiple Loops – an array within an array (loop in a loop)

_Step – step skip loop entries at a given rate

Option Explicit

‘Script written by mark.bearak

‘Script copyrighted by dtls.Architecture

‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()

Call Main()

Sub Main()

Dim arrPt, i, j

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPt = array(i,j,120)

Call Rhino.addPoint (arrPt)

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 3—————————-

_Auto-Replace – automatically updates words in script
_Relationship of Variables – always bundle like functions

Option Explicit

‘Script written by mark.bearak

‘Script copyrighted by dtls.Architecture

‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()

Call Main()

Sub Main()

Dim arrPta, i, j, arrPtb

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPta = array(i,j,120)

arrPtb = array(i,j,120-10)

Call Rhino.addPoint (arrPta)

Call Rhino.AddPoint (arrPtb)

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 4—————————-

_Call Rhino.addCone – creates a cone

Option Explicit

‘Script written by mark.bearak

‘Script copyrighted by dtls.Architecture

‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()

Call Main()

Sub Main()

Dim arrPta, i, j, arrPtb

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPta = array(i,j,120)

arrPtb = array(i,j,120-10)

Call Rhino.addPoint (arrPta)

Call Rhino.AddPoint (arrPtb)

Call Rhino.addcone (arrPta, arrPtb, 4)

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 5—————————-

_Get Point – pauses script for user to manually select a point in the modeling space

_Rhino.Distance – finds distance between 2 points

_Rhino.Print – prints variable in command line
_Rhino.Pt2Str – turns an array into a printable string

Option Explicit

‘Script written by mark.bearak

‘Script copyrighted by dtls.Architecture

‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()

Call Main()

Sub Main()

Dim arrPta, i, j, arrPtb, arrDistPt, dblDist

arrDistPt = Rhino.GetPoint (“select your locator”)

Call Rhino.Print (rhino.Pt2Str (arrDistPt))

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPta = array(i,j,120)

arrPtb = array(i,j,120-10)

dblDist = Rhino.Distance (arrDistPt,arrPta)

Call Rhino.Print (dblDist)

Call Rhino.addcone (arrPta, arrPtb, 4)

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 6—————————-

_Clean Up – Always clean up unused geometry

_Conscious Modification of inputs – take a look at the constraints of physical fabrication
_Parametric growth of geometry – look at digital limits

Option Explicit

‘Script written by mark.bearak

‘Script copyrighted by dtls.Architecture

‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()

Call Main()

Sub Main()

Dim arrPta, i, j, arrPtb, arrDistPt, dblDist

arrDistPt = Rhino.GetPoint (“select your locator”)

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPta = array(i,j,120)

dblDist = Rhino.Distance (arrDistPt,arrPta)

arrPtb = array(i,j,120-dblDist)

Call Rhino.addcone (arrPta, arrPtb, 4)

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 7—————————-

_Mathematical Scaling – applying a mathematical function to a variable
_Creating Limits – using if/then with a specific number
_If/Then – conditional statement

Option Explicit

‘Script written by mark.bearak

‘Script copyrighted by dtls.Architecture

‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()

Call Main()

Sub Main()

Dim arrPta, i, j, arrPtb, arrDistPt, dblDist

arrDistPt = Rhino.GetPoint (“select your locator”)

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPta = array(i,j,120)

dblDist = Rhino.Distance (arrDistPt,arrPta)

dblDist = dblDist/2

If dblDist > 36 Then

dblDist = 36

End If

arrPtb = array(i,j,120-dblDist)

Call Rhino.addcone (arrPta, arrPtb, 4)

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 8—————————-

_Fix – visual basics code for forcing a number into and integer – fix(variable)
_Mod – creates skipping from a specific start at a specific rate – if variable mod # = # then ….. end if

_Rhino.selectobject – selects a given object in the modeling space
_Rhino.Command – places a command line entry – example: (“Unrollsrf enter “)

Option Explicit

‘Script written by mark.bearak

‘Script copyrighted by dtls.Architecture

‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()

Call Main()

Sub Main()

Dim arrPta, i, j, arrPtb, arrDistPt, dblDist, strSrf, strUnrollSrf

arrDistPt = Rhino.GetPoint (“select your locator”)

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPta = array(i,j,120)

dblDist = Rhino.Distance (arrDistPt,arrPta)

dblDist = dblDist/2

If dblDist > 36 Then

dblDist = 36

End If

arrPtb = array(i,j,120-dblDist)

strSrf = Rhino.addcone (arrPta, arrPtb, 4)

Call Rhino.SelectObject (strSrf)

Call Rhino.Command (“unrollsrf enter”)

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 9—————————-

_First Object (really the last object) – extracts the ID of most recent object
_think about your production technique – always check the digital models against the constraints of the material
_Rhino.DuplicateSurfaceBorder – duplicates the border of surface
_Clean up your script – always clean up your script

Option Explicit

‘Script written by mark.bearak

‘Script copyrighted by dtls.Architecture

‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()

Call Main()

Sub Main()

Dim arrPta, i, j, arrPtb, arrDistPt, dblDist, strSrf, strUnrollSrf

arrDistPt = Rhino.GetPoint (“select your locator”)

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPta = array(i,j,120)

dblDist = Rhino.Distance (arrDistPt,arrPta)

dblDist = dblDist/2

If dblDist > 36 Then

dblDist = 36

End If

arrPtb = array(i,j,120-dblDist)

strSrf = Rhino.addcone (arrPta, arrPtb, 4)

Call Rhino.SelectObject (strSrf)

Call Rhino.Command (“unrollsrf enter”)

Call Rhino.UnselectAllObjects

strUnrollSrf = Rhino.FirstObject (True)

Call Rhino.DuplicateSurfaceBorder (strUnrollSrf)

Call Rhino.DeleteObject (strUnrollSrf)

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 10—————————-

_extracting elements from an array  – “for each string in array”
_laying out your boards – using the loop to facilitate the layout

Option Explicit

‘Script written by mark.bearak

‘Script copyrighted by dtls.Architecture

‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()

Call Main()

Sub Main()

Dim arrPta, i, j, arrPtb, arrDistPt, dblDist, strSrf, strUnrollSrf, arrBorders, strBorder

arrDistPt = Rhino.GetPoint (“select your locator”)

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPta = array(i,j,120)

dblDist = Rhino.Distance (arrDistPt,arrPta)

dblDist = dblDist/2

If dblDist > 36 Then

dblDist = 36

End If

arrPtb = array(i,j,120-dblDist)

strSrf = Rhino.addcone (arrPta, arrPtb, 4)

Call Rhino.SelectObject (strSrf)

Call Rhino.Command (“unrollsrf enter”)

Call Rhino.UnselectAllObjects

strUnrollSrf = Rhino.FirstObject (True)

arrBorders = Rhino.DuplicateSurfaceBorder (strUnrollSrf)

Call Rhino.DeleteObject (strUnrollSrf)

For Each strBorder In arrBorders

Call Rhino.MoveObject (strBorder, array(0,0,0),array(i*2,j*2,0))

Next

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

———————Step 11—————————-

-Creating a labeling method

Option Explicit

‘Script written by mark.bearak

‘Script copyrighted by dtls.Architecture

‘Script version Sunday, October 26, 2008 9:33:51 PM

Call Delete()

Call Main()

Sub Main()

Dim arrPta, i, j, arrPtb, arrDistPt, dblDist, strSrf, strUnrollSrf, arrBorders, strBorder

arrDistPt = Rhino.GetPoint (“select your locator”)

For i = 0 To 72 Step 24

For j = 0 To 120 Step 24

arrPta = array(i,j,120)

dblDist = Rhino.Distance (arrDistPt,arrPta)

dblDist = dblDist/2

If dblDist > 36 Then

dblDist = 36

End If

arrPtb = array(i,j,120-dblDist)

strSrf = Rhino.addcone (arrPta, arrPtb, 4)

Call Rhino.SelectObject (strSrf)

Call Rhino.Command (“unrollsrf enter”)

Call Rhino.UnselectAllObjects

strUnrollSrf = Rhino.FirstObject (True)

arrBorders = Rhino.DuplicateSurfaceBorder (strUnrollSrf)

Call Rhino.DeleteObject (strUnrollSrf)

For Each strBorder In arrBorders

Call Rhino.MoveObject (strBorder, array(0,0,0),array(i*2,j*2,0))

Next

Call Rhino.AddText (i/24 & j/24, array(i*2,(j*2)-6,0),6)

Next

Next

End Sub

Sub Delete()

Call Rhino.Command (“selall “)

Call Rhino.Command (“delete “)

End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s