Week 4

——————-Week 4 Homework——————–

1. Prepare your modeled material prototype for Class 5

2. Start working on your final script

——————-Week 4 Class Session——————–

This exercise will generate a panel system that can be assembled to make a curved wall. The script will use multiple distance based attractors and surface rationalization

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

Option Explicit
‘Script written by mark.bearak
‘Script copyrighted by dtls.Architecture
‘Script version Tuesday, November 11, 2008 7:06:57 PM

Call Main()
Sub Main()
Dim strSrf : strSrf = Rhino.GetObject (“Select a host surf”,12)
End Sub

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

_Surface Domain

_Incremental Steps

Call Main()
Sub Main()
Dim strSrf : strSrf = Rhino.GetObject (“Select a host surf”,12)
Dim intU : intU = 40 ‘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)
End Sub

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

_Surface Frame

_Step Addition

Call Main()
Sub Main()
Dim i,j,u,v
Dim strSrf : strSrf = Rhino.GetObject (“Select a host surf”,12)
Dim intU : intU = 24 ‘Horizontal
Dim intV : intV = 8 ‘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)
For j = 0 To intV
For i = 0 To intU
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)))
Next
Next
End Sub

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

_Create a Vertical Line

Call Main()
Sub Main()
Dim i,j,u,v
Dim strSrf : strSrf = Rhino.GetObject (“Select a host surf”,12)
Dim intU : intU = 24 ‘Horizontal
Dim intV : intV = 8 ‘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)
For j = 0 To intV
For i = 0 To intU
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)))
Call Rhino.AddLine (arrFrame(i,j)(0),Array(arrFrame(i,j)(0)(0),arrFrame(i,j)(0)(1),arrFrame(i,j)(0)(2)+10))
Next
Next
End Sub

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

_PointAdd

_VectorScale

Call Main()
Sub Main()
Dim i,j,u,v, arrPtNormal
Dim strSrf : strSrf = Rhino.GetObject (“Select a host surf”,12)
Dim intU : intU = 24 ‘Horizontal
Dim intV : intV = 8 ‘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)
For j = 0 To intV
For i = 0 To intU
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)))
arrPtNormal = Rhino.PointAdd(arrFrame(i,j)(0), Rhino.VectorScale (arrFrame(i,j)(3),VStep))
Call Rhino.AddLine (arrFrame(i,j)(0),arrPtNormal)
Next
Next
End Sub

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

_Add In Distance Based Attractors

Call Main()
Sub Main()
Dim i,j,u,v,k, arrPtNormal, strAttractor, arrAttractor, testDistance, dblDistance
Dim strSrf : strSrf = Rhino.GetObject (“Select a host surf”,12)
Dim arrStrAttractors : arrStrAttractors = Rhino.GetObjects (“Select points”,1)
ReDim arrAttractors(UBound(arrStrAttractors ))
Dim d : d = Rhino.GetInteger (“max distance of falloff?”, 60)
k=0
For Each strAttractor In arrStrAttractors
arrAttractors(k) = Rhino.pointcoordinates (strAttractor)
k=k+1
Next
Dim intU : intU = 24 ‘Horizontal
Dim intV : intV = 8 ‘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)
For j = 0 To intV
For i = 0 To intU
u = UDomain(0) + UStep * i
v = VDomain(0) + vStep * j
arrFrame(i,j) = Rhino.SurfaceFrame (strSrf, Array(U,V))
dblDistance = d
For Each arrAttractor In arrAttractors
testDistance = Rhino.Distance (arrFrame(i,j)(0), arrAttractor)
If testDistance < dblDistance Then
dblDistance = testDistance
End If
Next
dblDistance = dblDistance/5
Call Rhino.AddPoints (Array(arrFrame(i,j)(0)))
arrPtNormal = Rhino.PointAdd(arrFrame(i,j)(0), Rhino.VectorScale (arrFrame(i,j)(3),dblDistance))
Call Rhino.AddLine (arrFrame(i,j)(0),arrPtNormal)
Next
Next
End Sub

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

_Create a framework

Call Main()
Sub Main()
Dim i,j,u,v,k, strAttractor, arrAttractor, testDistance, dblDistance
Dim strSrf : strSrf = Rhino.GetObject (“Select a host surf”,12)
Dim arrStrAttractors : arrStrAttractors = Rhino.GetObjects (“Select points”,1)
ReDim arrAttractors(UBound(arrStrAttractors ))
Dim d : d = Rhino.GetInteger (“max distance of falloff?”, 60)
k=0
For Each strAttractor In arrStrAttractors
arrAttractors(k) = Rhino.pointcoordinates (strAttractor)
k=k+1
Next
Dim intU : intU = 24 ‘Horizontal
Dim intV : intV = 8 ‘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)
ReDim arrPtNormal(intU,intV)
For j = 0 To intV
For i = 0 To intU
u = UDomain(0) + UStep * i
v = VDomain(0) + vStep * j
arrFrame(i,j) = Rhino.SurfaceFrame (strSrf, Array(U,V))
dblDistance = d
For Each arrAttractor In arrAttractors
testDistance = Rhino.Distance (arrFrame(i,j)(0), arrAttractor)
If testDistance < dblDistance Then
dblDistance = testDistance
End If
Next
dblDistance = dblDistance/5
Call Rhino.AddPoints (Array(arrFrame(i,j)(0)))
arrPtNormal(i,j) = Rhino.PointAdd(arrFrame(i,j)(0), Rhino.VectorScale (arrFrame(i,j)(3),dblDistance))
Call Rhino.AddLine (arrFrame(i,j)(0),arrPtNormal(i,j))
If i > 0 And j > 0 Then
Call Rhino.AddLine (arrPtNormal(i,j),arrPtNormal(i-1,j-1))
Call Rhino.AddLine (arrPtNormal(i,j),arrPtNormal(i-1,j))
Call Rhino.AddLine (arrPtNormal(i,j),arrPtNormal(i,j-1))
Call Rhino.AddLine (arrPtNormal(i,j-1),arrPtNormal(i-1,j-1))
Call Rhino.AddLine (arrPtNormal(i-1,j),arrPtNormal(i-1,j-1))
End If
Next
Next
End Sub

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

_Add Panels

Call Main()
Sub Main()
Dim i,j,u,v,k, strAttractor, arrAttractor, testDistance, dblDistance, strCrv1, strCrv2, strCrv3, strCrv4, strCrv5
Dim strSrf : strSrf = Rhino.GetObject (“Select a host surf”,12)
Dim arrStrAttractors : arrStrAttractors = Rhino.GetObjects (“Select points”,1)
ReDim arrAttractors(UBound(arrStrAttractors ))
Dim d : d = Rhino.GetInteger (“max distance of falloff?”, 60)
k=0
For Each strAttractor In arrStrAttractors
arrAttractors(k) = Rhino.pointcoordinates (strAttractor)
k=k+1
Next
Dim intU : intU = 24 ‘Horizontal
Dim intV : intV = 8 ‘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)
ReDim arrPtNormal(intU,intV)
For j = 0 To intV
For i = 0 To intU
u = UDomain(0) + UStep * i
v = VDomain(0) + vStep * j
arrFrame(i,j) = Rhino.SurfaceFrame (strSrf, Array(U,V))
dblDistance = d
For Each arrAttractor In arrAttractors
testDistance = Rhino.Distance (arrFrame(i,j)(0), arrAttractor)
If testDistance < dblDistance Then
dblDistance = testDistance
End If
Next
dblDistance = dblDistance/5
Call Rhino.AddPoints (Array(arrFrame(i,j)(0)))
arrPtNormal(i,j) = Rhino.PointAdd(arrFrame(i,j)(0), Rhino.VectorScale (arrFrame(i,j)(3),dblDistance))
Call Rhino.AddLine (arrFrame(i,j)(0),arrPtNormal(i,j))
If i > 0 And j > 0 Then
strCrv1 = Rhino.AddLine (arrPtNormal(i,j),arrPtNormal(i-1,j-1))
strCrv2 = Rhino.AddLine (arrPtNormal(i,j),arrPtNormal(i-1,j))
strCrv3 = Rhino.AddLine (arrPtNormal(i,j),arrPtNormal(i,j-1))
strCrv4 = Rhino.AddLine (arrPtNormal(i,j-1),arrPtNormal(i-1,j-1))
strCrv5 = Rhino.AddLine (arrPtNormal(i-1,j),arrPtNormal(i-1,j-1))
Call Rhino.addPlanarSrf (Array(strCrv1, strCrv2, strCrv5))
Call Rhino.addPlanarSrf (Array(strCrv1, strCrv3, strCrv4))
End If
Next
Next
End Sub

——————-Week 4 Bonus Script——————–

Option Explicit
‘Script written by mark.bearak
‘Script copyrighted by dtls.architecture
‘Script version Tuesday, November 11, 2008 8:15:34 PM

Call Main()
Sub Main()
Dim i, j, k, strAttractor, dblDistance, arrAttractor, testDistance, arrPtsa(), arrPtsb(), counter, strCrva, strCrvb, arrLftSrf
Dim strSrf, arrExplodedSrf, arrUnrollSrfa, arrUnrollSrfb, strUnrolledSrf
Dim arrStrAttractors : arrStrAttractors = Rhino.GetObjects (“Select points”,1)
ReDim arrAttractors(UBound(arrStrAttractors))
Dim d : d = Rhino.GetInteger (“max distance of falloff?”, 36)
Dim strExtCrv : strExtCrv = Rhino.AddLine (Array(0,0,0),Array(0,0,-2.5))
k=0
For Each strAttractor In arrStrAttractors
arrAttractors(k) = Rhino.pointcoordinates (strAttractor)
k=k+1
Next
For i = 0 To 96 Step 12
counter = 0
For j = 0 To 192 Step 12
ReDim Preserve arrPtsa(counter)
ReDim Preserve arrPtsb(counter)
dblDistance = d
For Each arrAttractor In arrAttractors
testDistance = Rhino.Distance (Array(j,0,i), arrAttractor)
If testDistance < dblDistance Then
dblDistance = testDistance
End If
Next
dblDistance = dblDistance/3
arrPtsa(counter) = Array(j,0,i)
arrPtsb(counter) = Array(j,dblDistance,i)
counter = counter + 1
Next
strCrva = Rhino.addinterpCurve (arrPtsa)
strCrvb = Rhino.addinterpCurve (arrPtsb)
arrLftSrf = Rhino.addLoftSrf (Array(strCrva,strCrvb))
strSrf = Rhino.ExtrudeSurface (arrLftSrf(0), strExtCrv, True)
arrExplodedSrf = Rhino.ExplodePolysurfaces (strSrf, True)
arrUnrollSrfa = Rhino.joinsurfaces (Array(arrExplodedSrf(0),arrExplodedSrf(1),arrExplodedSrf(3)),True)
arrUnrollSrfb = arrExplodedSrf(2)
Call Rhino.UnselectAllObjects
Call Rhino.SelectObject (arrUnrollSrfa)
Call Rhino.Command (“unrollSrf e=n enter “)
Call Rhino.UnselectAllObjects
strUnrolledSrf = Rhino.FirstObject
Call Rhino.MoveObject (strUnrolledSrf, Array(0,0,0), Array(i*-3,0,0))
Call Rhino.DuplicateEdgeCurves (strUnrolledSrf)
Call Rhino.DeleteObject (strUnrolledSrf)
Call Rhino.SelectObject (arrUnrollSrfb)
Call Rhino.Command (“unrollSrf e=n enter “)
Call Rhino.UnselectAllObjects
strUnrolledSrf = Rhino.FirstObject
Call Rhino.MoveObject (strUnrolledSrf, Array(0,0,0), Array((i*-3)-16,0,0))
Call Rhino.DuplicateEdgeCurves (strUnrolledSrf)
Call Rhino.DeleteObject (strUnrolledSrf)
Call Rhino.DeleteObjects (Array(strCrva,strCrvb,arrLftSrf(0)))
Next
Call Rhino.DeleteObject (strExtCrv)
End Sub

——————-Week 4 Pre-Tutorial Session——————–

This session will introduce you to the concept of multiple distance based attractors. You will use the water-jet to cut out a shelving system for a vertical wall.

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

Option Explicit
‘Script written by mark.bearak
‘Script copyrighted by dtls.architecture
‘Script version Tuesday, November 11, 2008 8:15:34 PM

Call Main()
Sub Main()
Dim k, strAttractor
Dim arrStrAttractors : arrStrAttractors = Rhino.GetObjects (“Select points”,1)
ReDim arrAttractors(UBound(arrStrAttractors ))
Dim d : d = Rhino.GetInteger (“max distance of falloff?”, 20)
k=0
For Each strAttractor In arrStrAttractors
arrAttractors(k) = Rhino.pointcoordinates (strAttractor)
k=k+1
Next
End Sub

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

Call Main()
Sub Main()
Dim i, j, k, strAttractor
Dim arrStrAttractors : arrStrAttractors = Rhino.GetObjects (“Select points”,1)
ReDim arrAttractors(UBound(arrStrAttractors ))
Dim d : d = Rhino.GetInteger (“max distance of falloff?”, 20)
k=0
For Each strAttractor In arrStrAttractors
arrAttractors(k) = Rhino.pointcoordinates (strAttractor)
k=k+1
Next
For i = 0 To 96 Step 12
For j = 0 To 192 Step 12
Call Rhino.addPoint (array(j,0,i))
Next
Next
End Sub

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

_Create extrusions based on distance from locators

Call Main()
Sub Main()
Dim i, j, k, strAttractor, dblDistance, arrAttractor, testDistance
Dim arrStrAttractors : arrStrAttractors = Rhino.GetObjects (“Select points”,1)
ReDim arrAttractors(UBound(arrStrAttractors ))
Dim d : d = Rhino.GetInteger (“max distance of falloff?”, 36)
k=0
For Each strAttractor In arrStrAttractors
arrAttractors(k) = Rhino.pointcoordinates (strAttractor)
k=k+1
Next
For i = 0 To 96 Step 12
For j = 0 To 192 Step 12
dblDistance = d
For Each arrAttractor In arrAttractors
testDistance = Rhino.Distance (array(j,0,i), arrAttractor)
If testDistance < dblDistance Then
dblDistance = testDistance
End If
Next
dblDistance = dblDistance/3
Call Rhino.AddLine (array(j,0,i),array(j,dblDistance,i))
Next
Next
End Sub

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

_Create edge curves

Call Main()
Sub Main()
Dim i, j, k, strAttractor, dblDistance, arrAttractor, testDistance, arrPtsa(), arrPtsb(), counter
Dim arrStrAttractors : arrStrAttractors = Rhino.GetObjects (“Select points”,1)
ReDim arrAttractors(UBound(arrStrAttractors ))
Dim d : d = Rhino.GetInteger (“max distance of falloff?”, 36)
k=0
For Each strAttractor In arrStrAttractors
arrAttractors(k) = Rhino.pointcoordinates (strAttractor)
k=k+1
Next
For i = 0 To 96 Step 12
counter = 0
For j = 0 To 192 Step 12
ReDim Preserve arrPtsa(counter)
ReDim Preserve arrPtsb(counter)
dblDistance = d
For Each arrAttractor In arrAttractors
testDistance = Rhino.Distance (array(j,0,i), arrAttractor)
If testDistance < dblDistance Then
dblDistance = testDistance
End If
Next
dblDistance = dblDistance/3
arrPtsa(counter) = array(j,0,i)
arrPtsb(counter) = array(j,dblDistance,i)
counter = counter + 1
Next
Call Rhino.addinterpCurve (arrPtsa)
Call Rhino.addinterpCurve (arrPtsb)
Next
End Sub

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

_Add extruded surface

_Clean up unused geometry

Call Main()
Sub Main()
Dim i, j, k, strAttractor, dblDistance, arrAttractor, testDistance, arrPtsa(), arrPtsb(), counter, strCrva, strCrvb, arrLftSrf
Dim arrStrAttractors : arrStrAttractors = Rhino.GetObjects (“Select points”,1)
ReDim arrAttractors(UBound(arrStrAttractors ))
Dim d : d = Rhino.GetInteger (“max distance of falloff?”, 36)
Dim strExtCrv : strExtCrv = Rhino.AddLine (array(0,0,0),array(0,0,-2))
k=0
For Each strAttractor In arrStrAttractors
arrAttractors(k) = Rhino.pointcoordinates (strAttractor)
k=k+1
Next
For i = 0 To 96 Step 12
counter = 0
For j = 0 To 192 Step 12
ReDim Preserve arrPtsa(counter)
ReDim Preserve arrPtsb(counter)
dblDistance = d
For Each arrAttractor In arrAttractors
testDistance = Rhino.Distance (array(j,0,i), arrAttractor)
If testDistance < dblDistance Then
dblDistance = testDistance
End If
Next
dblDistance = dblDistance/3
arrPtsa(counter) = array(j,0,i)
arrPtsb(counter) = array(j,dblDistance,i)
counter = counter + 1
Next
strCrva = Rhino.addinterpCurve (arrPtsa)
strCrvb = Rhino.addinterpCurve (arrPtsb)
arrLftSrf = Rhino.addLoftSrf (array(strCrva,strCrvb))
Call Rhino.ExtrudeSurface (arrLftSrf(0), strExtCrv, True)
Call Rhino.DeleteObjects (array(strCrva,strCrvb,arrLftSrf(0)))
Next
Call Rhino.DeleteObject (strExtCrv)
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