homework + project proposal

week23

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*sin(i*j/48))*4)
    arrNewPtc = array(arrPt(0),arrPt(1),arrPt(2)-(dblDist*cos(i*j/48)*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

pr_project

pr_oma_project1

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