Therese Diede _ lights _wk2

Option Explicit
‘Script written by mark.bearak, adapted by therese.diede

‘Script copyrighted by dtls.Architecture

‘Script version Wednesday, November 5, 2008 10:30:00 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, arrNewPtd, 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))

arrNewPtd = Array(arrPt(0),arrPt(1),arrPt(Sin(i/24))-(dblDist*4))

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

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

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

td_lights_wk2

Advertisements

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