hyunchang cho-wk2

lamp-wk2

Option Explicit
‘Script written by Hyunchang Cho
‘Script copyrighted by gsapp
‘Script version Thursday, November 06, 2008 2:30:34 AM

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, arrNewPte, arrNewPtf
 Dim 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,24)
   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*3/5)
    arrNewPtb = array(arrNewPta(0),arrNewPta(1),arrNewPta(2)-dblDist)
    arrNewPtf = Rhino.Polar (arrPt, k, (dblDist*1.5))
    arrNewPtc = array(arrNewPtf(0),arrNewPtf(1),arrNewPtf(2)-(dblDist*2))
    arrNewPtd = array(arrPt(0),arrPt(1),arrPt(2)-(dblDist*3))
    arrNewPte = array(arrPt(0),arrPt(1),arrPt(2)-(dblDist*5))    
    
    strCrva(counter) = Rhino.AddLine (arrPt, arrNewPta)
    strCrvb(counter) = Rhino.AddCurve (array(arrNewPta,arrNewPtb,arrNewPtc,arrNewPtd,arrNewPte))
    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),5)
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

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