Week 5

——————-Week 5 Homework——————–

1. Focus on studio

2. Final gathering will be at 6:00 on Friday, December 12th in Ware Lounge

——————-Week 5 Class Session——————–

 This session will introduce you to the concept of L-Systems. We will use the L-System to generate a dome structure.

 

 

———————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 arrPoint : arrPoint = Rhino.getPoint (“Select your start point”)
End Sub

 

 

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

Call Main()
Sub Main()
  Dim i
  Dim arrPoint : arrPoint = Rhino.getPoint
  Dim dblLength : dblLength = 8
  For i = -180 To 179 Step 90
    Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrPoint, i, 10)
    Call Rhino.AddLine (arrPoint, arrNewPoint)
  Next
End Sub

 

 

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

Call Main()
Sub Main()
  Dim i, strCrv
  Dim arrPoint : arrPoint = Rhino.getPoint
  Dim dblLength : dblLength = 8
  For i = -180 To 179 Step 90
    Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrPoint, i, 10)
    strCrv = Rhino.AddLine (arrPoint, arrNewPoint)
    Call LSystem(strCrv)
  Next
End Sub

Function LSystem(strCrv)
  Dim arrNewestPt, strNewCrv, tempAnglea, tempAngleb
  Dim arrNewPt : arrNewPt = Rhino.CurveEndPoint (strCrv)
  Dim dblDist : dblDist = Rhino.CurveLength (strCrv)
  Dim dblAngle : dblAngle = Rhino.Angle (Rhino.CurveStartPoint (strCrv), Rhino.CurveEndPoint (strCrv))
  Call Rhino.Print (“Angle: ” & CStr(dblAngle(0)))
  dblDist = dblDist – 1
  tempAnglea = dblAngle(0) – 10
  If dblDist > 0 Then
    arrNewestPt = Rhino.Polar (arrNewPt, tempAnglea, dblDist)
    strNewCrv = Rhino.addLine (arrNewPt,arrNewestPt)
    Call LSystem(strNewCrv)
  End If
End Function

 

 

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

Call Main()
Sub Main()
  Dim i, strCrv
  Dim arrPoint : arrPoint = Rhino.getPoint
  Dim dblLength : dblLength = 8
  For i = -180 To 179 Step 90
    Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrPoint, i, 10)
    strCrv = Rhino.AddLine (arrPoint, arrNewPoint)
    Call LSystem(strCrv)
  Next
End Sub

Function LSystem(strCrv)
  Dim i, arrNewestPt, strNewCrv, tempAnglea, tempAngleb
  Dim arrNewPt : arrNewPt = Rhino.CurveEndPoint (strCrv)
  Dim dblDist : dblDist = Rhino.CurveLength (strCrv)
  Dim dblAngle : dblAngle = Rhino.Angle (Rhino.CurveStartPoint (strCrv), Rhino.CurveEndPoint (strCrv))
  dblDist = dblDist – 1
  If dblDist > 1 Then
    For i = 0 To 1
      If i Mod 2 = 0 Then
        tempAnglea = dblAngle(0) – 20
      Else
        tempAnglea = dblAngle(0) + 20
      End If
      arrNewestPt = Rhino.Polar (arrNewPt, tempAnglea, dblDist)
      strNewCrv = Rhino.addLine (arrNewPt,arrNewestPt)
      Call LSystem(strNewCrv)
    Next
  End If
End Function

 

 

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

Call Main()
Sub Main()
  Dim i, strCrv, strCrvCount(), counter
  Dim arrPoint : arrPoint = Rhino.getPoint
  Dim dblLength : dblLength = 8
  counter = -1
  For i = -180 To 179 Step 90
    Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrPoint, i, 10)
    strCrv = Rhino.AddLine (arrPoint, arrNewPoint)
    counter = counter + 1
    ReDim Preserve strCrvCount(counter)
    strCrvCount(counter) = strCrv
    Call LSystem(strCrv,counter,strCrvCount)
  Next
  Call Rhino.SelectObjects (strCrvCount)
End Sub

Function LSystem(strCrv,counter,strCrvCount)
  Dim i, arrNewestPt, strNewCrv, tempAnglea, tempAngleb
  Dim arrNewPt : arrNewPt = Rhino.CurveEndPoint (strCrv)
  Dim dblDist : dblDist = Rhino.CurveLength (strCrv)
  Dim dblAngle : dblAngle = Rhino.Angle (Rhino.CurveStartPoint (strCrv), Rhino.CurveEndPoint (strCrv))
  dblDist = dblDist – 1
  If dblDist > 1 Then
    For i = 0 To 1
      If i Mod 2 = 0 Then
        tempAnglea = dblAngle(0) – 20
      Else
        tempAnglea = dblAngle(0) + 20
      End If
      arrNewestPt = Rhino.Polar (arrNewPt, tempAnglea, dblDist)
      strNewCrv = Rhino.addLine (arrNewPt,arrNewestPt)
      counter = counter + 1
      ReDim Preserve strCrvCount(counter)
      strCrvCount(counter) = strNewCrv
      Call LSystem(strNewCrv,counter,strCrvCount)
    Next
  End If
End Function

 

 

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

Call Main()
Sub Main()
  Dim i, strCrv, strCrvCount(), counter
  Dim arrPoint : arrPoint = Rhino.getPoint
  Dim dblLength : dblLength = 8
  counter = -1
  For i = -180 To 179 Step 90
    Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrPoint, i, 10)
    strCrv = Rhino.AddLine (arrPoint, arrNewPoint)
    counter = counter + 1
    ReDim Preserve strCrvCount(counter)
    strCrvCount(counter) = strCrv
    Call LSystem(strCrv,counter,strCrvCount)
  Next
  Call Rhino.SelectObjects (strCrvCount)
End Sub

Function LSystem(strCrv,counter,strCrvCount)
  Dim i,n, arrNewestPt, strNewCrv, tempAnglea, tempAngleb, strCrvCt, arrCCX, intCounter
  Dim arrNewPt : arrNewPt = Rhino.CurveEndPoint (strCrv)
  Dim dblDist : dblDist = Rhino.CurveLength (strCrv)
  Dim dblAngle : dblAngle = Rhino.Angle (Rhino.CurveStartPoint (strCrv), Rhino.CurveEndPoint (strCrv))
  n=0
  dblDist = dblDist – 1
  If dblDist > 1 Then
    For i = 0 To 1
      If i Mod 2 = 0 Then
        tempAnglea = dblAngle(0) – 20
      Else
        tempAnglea = dblAngle(0) + 20
      End If
      arrNewestPt = Rhino.Polar (arrNewPt, tempAnglea, dblDist)
      strNewCrv = Rhino.addLine (arrNewPt,arrNewestPt)
      intCounter = 0
      For Each strCrvCt In strCrvCount
        arrCCX = Rhino.CurveCurveIntersection (strCrvCt, strNewCrv)
        If IsArray (arrCCX) Then
          If (Rhino.Pt2Str(Rhino.CurveStartPoint (strNewCrv)) <> Rhino.Pt2Str(Rhino.CurveEndPoint (strCrvCt))) Then
            If (Rhino.Pt2Str(Rhino.CurveEndPoint (strNewCrv)) <> Rhino.Pt2Str(Rhino.CurveStartPoint (strCrvCt))) Then
              If (Rhino.Pt2Str(Rhino.CurveStartPoint (strNewCrv)) <> Rhino.Pt2Str(Rhino.CurveStartPoint (strCrvCt))) Then
                Call Rhino.AddPoint (arrCCX(n,1))
              End If
            End If
          End If
        End If
      Next
      counter = counter + 1
      ReDim Preserve strCrvCount(counter)
      strCrvCount(counter) = strNewCrv
      Call LSystem(strNewCrv,counter,strCrvCount)
    Next
  End If
End Function

 

 

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

 Call Main()
Sub Main()
  Dim i, strCrv, strCrvCount(), counter
  Dim arrPoint : arrPoint = Rhino.getPoint
  Dim dblLength : dblLength = 8
  counter = -1
  For i = -180 To 179 Step 90
    Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrPoint, i, 10)
    strCrv = Rhino.AddLine (arrPoint, arrNewPoint)
    counter = counter + 1
    ReDim Preserve strCrvCount(counter)
    strCrvCount(counter) = strCrv
    Call LSystem(strCrv,counter,strCrvCount)
  Next
End Sub

Function LSystem(strCrv,counter,strCrvCount)
  Dim i,n, arrNewestPt, strNewCrv, tempAnglea, tempAngleb, strCrvCt, arrCCX, intCounter, strTempCrv, arrIntPt()
  Dim arrNewPt : arrNewPt = Rhino.CurveEndPoint (strCrv)
  Dim dblDist : dblDist = Rhino.CurveLength (strCrv)
  Dim dblAngle : dblAngle = Rhino.Angle (Rhino.CurveStartPoint (strCrv), Rhino.CurveEndPoint (strCrv))
  n=0
  dblDist = dblDist – 1
  If dblDist > 1 Then
    For i = 0 To 1
      If i Mod 2 = 0 Then
        tempAnglea = dblAngle(0) – 20
      Else
        tempAnglea = dblAngle(0) + 20
      End If
      arrNewestPt = Rhino.Polar (arrNewPt, tempAnglea, dblDist)
      strTempCrv = Rhino.addLine (arrNewPt,arrNewestPt)
      intCounter = 0
      For Each strCrvCt In strCrvCount
        arrCCX = Rhino.CurveCurveIntersection (strCrvCt, strTempCrv)
        If IsArray (arrCCX) Then
          If (Rhino.Pt2Str(Rhino.CurveStartPoint (strTempCrv)) <> Rhino.Pt2Str(Rhino.CurveEndPoint (strCrvCt))) Then
            If (Rhino.Pt2Str(Rhino.CurveEndPoint (strTempCrv)) <> Rhino.Pt2Str(Rhino.CurveStartPoint (strCrvCt))) Then
              If (Rhino.Pt2Str(Rhino.CurveStartPoint (strTempCrv)) <> Rhino.Pt2Str(Rhino.CurveStartPoint (strCrvCt))) Then
                ReDim Preserve arrIntPt(intCounter)
                arrIntPt(intCounter) = arrCCX(n,1)
                intCounter = intCounter + 1
              End If
            End If
          End If
        End If
      Next
     
      If intCounter > 0 Then
        Call Rhino.Deleteobject (strTempCrv)
      Else
        strNewCrv = strTempCrv
        counter = counter + 1
        ReDim Preserve strCrvCount(counter)
        strCrvCount(counter) = strNewCrv
        Call LSystem(strNewCrv,counter,strCrvCount)
      End If
    Next
  End If
End Function

 

 

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

 Call Main()
Sub Main()
  Dim i, strCrv, strCrvCount(), counter
  Dim arrPoint : arrPoint = Rhino.getPoint
  Dim dblLength : dblLength = 8
  counter = -1
  For i = -180 To 179 Step 90
    Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrPoint, i, 10)
    strCrv = Rhino.AddLine (arrPoint, arrNewPoint)
    counter = counter + 1
    ReDim Preserve strCrvCount(counter)
    strCrvCount(counter) = strCrv
    Call LSystem(strCrv,counter,strCrvCount)
  Next
End Sub

Function LSystem(strCrv,counter,strCrvCount)
  Dim i,n, arrNewestPt, strNewCrv, tempAnglea, tempAngleb, strCrvCt, arrCCX, intCounter, strTempCrv, arrIntPt, arrIntPts(), tempDistance, dblDistance, NewEndPoint
  Dim arrNewPt : arrNewPt = Rhino.CurveEndPoint (strCrv)
  Dim dblDist : dblDist = Rhino.CurveLength (strCrv)
  Dim dblAngle : dblAngle = Rhino.Angle (Rhino.CurveStartPoint (strCrv), Rhino.CurveEndPoint (strCrv))
  n=0
  dblDist = dblDist – 1
  dblDistance = 1000000
  If dblDist > 1 Then
    For i = 0 To 1
      If i Mod 2 = 0 Then
        tempAnglea = dblAngle(0) – 20
      Else
        tempAnglea = dblAngle(0) + 20
      End If
      arrNewestPt = Rhino.Polar (arrNewPt, tempAnglea, dblDist)
      strTempCrv = Rhino.addLine (arrNewPt,arrNewestPt)
      intCounter = 0
      For Each strCrvCt In strCrvCount
        arrCCX = Rhino.CurveCurveIntersection (strCrvCt, strTempCrv)
        If IsArray (arrCCX) Then
          If (Rhino.Pt2Str(Rhino.CurveStartPoint (strTempCrv)) <> Rhino.Pt2Str(Rhino.CurveEndPoint (strCrvCt))) Then
            If (Rhino.Pt2Str(Rhino.CurveEndPoint (strTempCrv)) <> Rhino.Pt2Str(Rhino.CurveStartPoint (strCrvCt))) Then
              If (Rhino.Pt2Str(Rhino.CurveStartPoint (strTempCrv)) <> Rhino.Pt2Str(Rhino.CurveStartPoint (strCrvCt))) Then
                ReDim Preserve arrIntPts(intCounter)
                arrIntPts(intCounter) = arrCCX(n,1)
                intCounter = intCounter + 1
              End If
            End If
          End If
        End If
      Next
     
      If intCounter > 0 Then
        For Each arrIntPt In arrIntPts
          tempDistance = Rhino.Distance (Rhino.CurveStartPoint (strTempCrv),arrIntPt)
          If tempDistance < dblDistance Then
            dblDistance = tempDistance
            NewEndPoint = arrIntPt
          End If
        Next
        strNewCrv = Rhino.AddLine (Rhino.CurveStartPoint (strTempCrv),NewEndPoint)
        Call Rhino.Deleteobject (strTempCrv)
        counter = counter + 1
        ReDim Preserve strCrvCount(counter)
        strCrvCount(counter) = strNewCrv
      Else
        strNewCrv = strTempCrv
        counter = counter + 1
        ReDim Preserve strCrvCount(counter)
        strCrvCount(counter) = strNewCrv
        Call LSystem(strNewCrv,counter,strCrvCount)
      End If
    Next
  End If
End Function

 

 

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

 Call Main()
Sub Main()
  Dim i, strCrv, strCrvCount(), counter, arrTopPt, dblheight
  Dim arrPoint : arrPoint = Rhino.getPoint
  Dim dblLength : dblLength = 8
  counter = -1
  For i = -180 To 179 Step 90
    dblHeight = 12
    arrtopPt = Array(arrPoint(0),arrPoint(1),arrPoint(2)+dblHeight)
    Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrtopPt, i, 10)
    strCrv = Rhino.AddLine (arrtopPt, arrNewPoint)
    counter = counter + 1
    ReDim Preserve strCrvCount(counter)
    strCrvCount(counter) = strCrv
    Call LSystem(strCrv,counter,strCrvCount,arrTopPt(2))
  Next
End Sub

Function LSystem(strCrv,counter,strCrvCount,dblHeight)
  Dim i,n, arrNewestPt, strNewCrv, tempAnglea, tempAngleb, strCrvCt, arrCCX, intCounter, strTempCrv, arrIntPt, arrIntPts(), tempDistance, dblDistance, NewEndPoint
  Dim arrNewPt : arrNewPt = Rhino.CurveEndPoint (strCrv)
  Dim dblDist : dblDist = Rhino.CurveLength (strCrv)
  Dim dblAngle : dblAngle = Rhino.Angle (Rhino.CurveStartPoint (strCrv), Rhino.CurveEndPoint (strCrv))
  n=0
  dblDist = dblDist – 1.5
  dblDistance = 1000000
  If dblHeight > 0 Then
    For i = 0 To 1
      If i Mod 2 = 0 Then
        tempAnglea = dblAngle(0) – 20
      Else
        tempAnglea = dblAngle(0) + 20
      End If
      arrNewestPt = Rhino.Polar (arrNewPt, tempAnglea, dblDist)
      strTempCrv = Rhino.addLine (arrNewPt,Array(arrNewestPt(0),arrNewestPt(1),arrNewestPt(2)-2))
      dblHeight = arrNewestPt(2)-2
      intCounter = 0
      For Each strCrvCt In strCrvCount
        arrCCX = Rhino.CurveCurveIntersection (strCrvCt, strTempCrv)
        If IsArray (arrCCX) Then
          If (Rhino.Pt2Str(Rhino.CurveStartPoint (strTempCrv)) <> Rhino.Pt2Str(Rhino.CurveEndPoint (strCrvCt))) Then
            If (Rhino.Pt2Str(Rhino.CurveEndPoint (strTempCrv)) <> Rhino.Pt2Str(Rhino.CurveStartPoint (strCrvCt))) Then
              If (Rhino.Pt2Str(Rhino.CurveStartPoint (strTempCrv)) <> Rhino.Pt2Str(Rhino.CurveStartPoint (strCrvCt))) Then
                ReDim Preserve arrIntPts(intCounter)
                arrIntPts(intCounter) = arrCCX(n,1)
                intCounter = intCounter + 1
              End If
            End If
          End If
        End If
      Next
     
      If intCounter > 0 Then
        For Each arrIntPt In arrIntPts
          tempDistance = Rhino.Distance (Rhino.CurveStartPoint (strTempCrv),arrIntPt)
          If tempDistance < dblDistance Then
            dblDistance = tempDistance
            NewEndPoint = arrIntPt
          End If
        Next
        strNewCrv = Rhino.AddLine (Rhino.CurveStartPoint (strTempCrv),NewEndPoint)
        Call Rhino.Deleteobject (strTempCrv)
        counter = counter + 1
        ReDim Preserve strCrvCount(counter)
        strCrvCount(counter) = strNewCrv
      Else
        strNewCrv = strTempCrv
        counter = counter + 1
        ReDim Preserve strCrvCount(counter)
        strCrvCount(counter) = strNewCrv
        Call LSystem(strNewCrv,counter,strCrvCount,dblHeight)
      End If
    Next
  End If
End Function

 

 

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

 Call Main()
Sub Main()
  Dim i,j, strCrv, strCrvCount(), counter, arrTopPt, dblheight, strCrvCt, strPath, strExtSrf, strOffSrfa, strOffSrfb, arrDupEdgea, arrDupEdgeb
  Dim arrPoint : arrPoint = Rhino.getPoint
  Dim dblLength : dblLength = 8
  counter = -1
  For i = -180 To 179 Step 90
    dblHeight = 12
    arrtopPt = Array(arrPoint(0),arrPoint(1),arrPoint(2)+dblHeight)
    Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrtopPt, i, 10)
    strCrv = Rhino.AddLine (arrtopPt, arrNewPoint)
    counter = counter + 1
    ReDim Preserve strCrvCount(counter)
    strCrvCount(counter) = strCrv
    Call LSystem(strCrv,counter,strCrvCount,arrTopPt(2))
  Next
  strPath = Rhino.addLine (Array(0,0,0),Array(0,0,-0.3))
  For Each strCrvCt In strCrvCount
    strExtSrf = Rhino.ExtrudeCurve (strCrvCt, strPath)
    strOffSrfa = Rhino.OffsetSurface (strExtSrf, 0.065)
    Call Rhino.FlipSurface (strExtSrf, True)
    strOffSrfb = Rhino.OffsetSurface (strExtSrf, 0.065)
    Call Rhino.DeleteObject (strExtSrf)
    arrDupEdgea = Rhino.DuplicateEdgeCurves (strOffSrfa)
    arrDupEdgeb = Rhino.DuplicateEdgeCurves (strOffSrfb)
    For j = 0 To UBound(arrDupEdgea)
      Call Rhino.AddLoftSrf (Array(arrDupEdgea(j),arrDupEdgeb(j)))
    Next
  Next
  Call Rhino.command (“selcrv “)
  Call Rhino.command (“delete “)
End Sub

Function LSystem(strCrv,counter,strCrvCount,dblHeight)
  Dim i,n, arrNewestPt, strNewCrv, tempAnglea, tempAngleb, strCrvCt, arrCCX, intCounter, strTempCrv, arrIntPt, arrIntPts(), tempDistance, dblDistance, NewEndPoint
  Dim arrNewPt : arrNewPt = Rhino.CurveEndPoint (strCrv)
  Dim dblDist : dblDist = Rhino.CurveLength (strCrv)
  Dim dblAngle : dblAngle = Rhino.Angle (Rhino.CurveStartPoint (strCrv), Rhino.CurveEndPoint (strCrv))
  n=0
  dblDist = dblDist – 1.5
  dblDistance = 1000000
  If dblHeight > 0 Then
    For i = 0 To 1
      If i Mod 2 = 0 Then
        tempAnglea = dblAngle(0) – 20
      Else
        tempAnglea = dblAngle(0) + 20
      End If
      arrNewestPt = Rhino.Polar (arrNewPt, tempAnglea, dblDist)
      strTempCrv = Rhino.addLine (arrNewPt,Array(arrNewestPt(0),arrNewestPt(1),arrNewestPt(2)-2))
      dblHeight = arrNewestPt(2)-2
      intCounter = 0
      For Each strCrvCt In strCrvCount
        arrCCX = Rhino.CurveCurveIntersection (strCrvCt, strTempCrv)
        If IsArray (arrCCX) Then
          If (Rhino.Pt2Str(Rhino.CurveStartPoint (strTempCrv)) <> Rhino.Pt2Str(Rhino.CurveEndPoint (strCrvCt))) Then
            If (Rhino.Pt2Str(Rhino.CurveEndPoint (strTempCrv)) <> Rhino.Pt2Str(Rhino.CurveStartPoint (strCrvCt))) Then
              If (Rhino.Pt2Str(Rhino.CurveStartPoint (strTempCrv)) <> Rhino.Pt2Str(Rhino.CurveStartPoint (strCrvCt))) Then
                ReDim Preserve arrIntPts(intCounter)
                arrIntPts(intCounter) = arrCCX(n,1)
                intCounter = intCounter + 1
              End If
            End If
          End If
        End If
      Next
     
      If intCounter > 0 Then
        For Each arrIntPt In arrIntPts
          tempDistance = Rhino.Distance (Rhino.CurveStartPoint (strTempCrv),arrIntPt)
          If tempDistance < dblDistance Then
            dblDistance = tempDistance
            NewEndPoint = arrIntPt
          End If
        Next
        strNewCrv = Rhino.AddLine (Rhino.CurveStartPoint (strTempCrv),NewEndPoint)
        Call Rhino.Deleteobject (strTempCrv)
        counter = counter + 1
        ReDim Preserve strCrvCount(counter)
        strCrvCount(counter) = strNewCrv
      Else
        strNewCrv = strTempCrv
        counter = counter + 1
        ReDim Preserve strCrvCount(counter)
        strCrvCount(counter) = strNewCrv
        Call LSystem(strNewCrv,counter,strCrvCount,dblHeight)
      End If
    Next
  End If
End Function

 

 

——————-Week 5 Pre-Tutorial Session——————–

This session will introduce you to the concept of L-Systems. We will use the L-System to generate a dome structure.

 

———————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 arrPoint : arrPoint = Rhino.getPoint (“Select your start point”)
End Sub

 

 

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

_Polar

Call Main()
Sub Main()
  Dim arrPoint : arrPoint = Rhino.getPoint

  Dim dblLength : dblLength = 8
  Dim dblAngle : dblAngle = 90
  Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrPoint, dblAngle, 10)
  Call Rhino.AddLine (arrPoint, arrNewPoint)
End Sub

 

 

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

_Function

_Curve End Point

_Curve Length

_Angle

_Recursive Functions

Call Main()
Sub Main()
  Dim arrPoint : arrPoint = Rhino.getPoint
  Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrPoint, 90, 10)
  Dim strCrv : strCrv = Rhino.AddLine (arrPoint, arrNewPoint)
  Call LSystem(strCrv)
End Sub

Function LSystem(strCrv)
  Dim arrNewestPt, strNewCrv, tempAnglea, tempAngleb
  Dim arrNewPt : arrNewPt = Rhino.CurveEndPoint (strCrv)
  Dim dblDist : dblDist = Rhino.CurveLength (strCrv)
  Dim dblAngle : dblAngle = Rhino.Angle (Rhino.CurveStartPoint (strCrv), Rhino.CurveEndPoint (strCrv))
  Call Rhino.Print (“Angle: ” & CStr(dblAngle(0)))
  dblDist = dblDist – 1
  tempAnglea = dblAngle(0) – 10
  If dblDist > 0 Then
    arrNewestPt = Rhino.Polar (arrNewPt, tempAnglea, dblDist)
    strNewCrv = Rhino.addLine (arrNewPt,arrNewestPt)
    Call LSystem(strNewCrv)
  End If
End Function

 

 

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

_Adding If/Then

_Bifrication of lines

Call Main()
Sub Main()
  Dim arrPoint : arrPoint = Rhino.getPoint
  Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrPoint, 90, 10)
  Dim strCrv : strCrv = Rhino.AddLine (arrPoint, arrNewPoint)
  Call LSystem(strCrv)
End Sub

Function LSystem(strCrv)
  Dim i, arrNewestPt, strNewCrv, tempAnglea, tempAngleb
  Dim arrNewPt : arrNewPt = Rhino.CurveEndPoint (strCrv)
  Dim dblDist : dblDist = Rhino.CurveLength (strCrv)
  Dim dblAngle : dblAngle = Rhino.Angle (Rhino.CurveStartPoint (strCrv), Rhino.CurveEndPoint (strCrv))
  dblDist = dblDist – 1
  If dblDist > 1 Then
    For i = 0 To 1
      If i Mod 2 = 0 Then
        tempAnglea = dblAngle(0) – 20
      Else
        tempAnglea = dblAngle(0) + 20
      End If
      arrNewestPt = Rhino.Polar (arrNewPt, tempAnglea, dblDist)
      strNewCrv = Rhino.addLine (arrNewPt,arrNewestPt)
      Call LSystem(strNewCrv)
    Next
  End If
End Function

 

 

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

_Randomization of strands

Call Main()
Sub Main()
  Dim arrPoint : arrPoint = Rhino.getPoint
  Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrPoint, 90, 10)
  Dim strCrv : strCrv = Rhino.AddLine (arrPoint, arrNewPoint)
  Call LSystem(strCrv)
End Sub

Function LSystem(strCrv)
  Dim i, arrNewestPt, strNewCrv, tempAnglea, tempAngleb, intRandom
  Dim arrNewPt : arrNewPt = Rhino.CurveEndPoint (strCrv)
  Dim dblDist : dblDist = Rhino.CurveLength (strCrv)
  Dim dblAngle : dblAngle = Rhino.Angle (Rhino.CurveStartPoint (strCrv), Rhino.CurveEndPoint (strCrv))
  dblDist = dblDist – 1
  If dblDist > .1 Then
    intRandom = Random(0, 2)
    Call Rhino.Print (intRandom)
    For i = 0 To intRandom
      If i Mod 2 = 0 Then
        tempAnglea = dblAngle(0) – 20
      Else
        tempAnglea = dblAngle(0) + 20
      End If
      arrNewestPt = Rhino.Polar (arrNewPt, tempAnglea, dblDist)
      strNewCrv = Rhino.addLine (arrNewPt,arrNewestPt)
      Call LSystem(strNewCrv)
    Next
  End If
End Function

Function Random(nMin, nMax)
  Randomize
  Random = Int((nMax – nMin + 1) * Rnd + nMin)
End Function

 

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

_Loop in Sub

Call Main()
Sub Main()
  Dim i
  Dim arrPoint : arrPoint = Rhino.getPoint
  For i = -180 To 179 Step 90
    Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrPoint, i, 10)
    Dim strCrv : strCrv = Rhino.AddLine (arrPoint, arrNewPoint)
    Call LSystem(strCrv)
  Next
End Sub

Function LSystem(strCrv)
  Dim i, arrNewestPt, strNewCrv, tempAnglea, tempAngleb, intRandom
  Dim arrNewPt : arrNewPt = Rhino.CurveEndPoint (strCrv)
  Dim dblDist : dblDist = Rhino.CurveLength (strCrv)
  Dim dblAngle : dblAngle = Rhino.Angle (Rhino.CurveStartPoint (strCrv), Rhino.CurveEndPoint (strCrv))
  dblDist = dblDist – 1
  If dblDist > .1 Then
    intRandom = Random(0, 2)
    For i = 0 To intRandom
      If i Mod 2 = 0 Then
        tempAnglea = dblAngle(0) – 20
      Else
        tempAnglea = dblAngle(0) + 20
      End If
      arrNewestPt = Rhino.Polar (arrNewPt, tempAnglea, dblDist)
      strNewCrv = Rhino.addLine (arrNewPt,arrNewestPt)
      Call LSystem(strNewCrv)
    Next
  End If
End Function

Function Random(nMin, nMax)
  Randomize
  Random = Int((nMax – nMin + 1) * Rnd + nMin)
End Function

 

 

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

_Changes in Vertical Height

Call Main()
Sub Main()
  Dim i
  Dim arrPoint : arrPoint = Rhino.getPoint
  For i = -180 To 179 Step 90
    Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrPoint, i, 10)
    Dim strCrv : strCrv = Rhino.AddLine (arrPoint, arrNewPoint)
    Call LSystem(strCrv)
  Next
End Sub

Function LSystem(strCrv)
  Dim i, arrNewestPt, strNewCrv, tempAnglea, tempAngleb, intRandom
  Dim arrNewPt : arrNewPt = Rhino.CurveEndPoint (strCrv)
  Dim dblDist : dblDist = Rhino.CurveLength (strCrv)
  Dim dblAngle : dblAngle = Rhino.Angle (Rhino.CurveStartPoint (strCrv), Rhino.CurveEndPoint (strCrv))
  dblDist = dblDist – 1.25
  If dblDist > 2 Then
    intRandom = Random(0, 2)
    For i = 0 To intRandom
      If i Mod 2 = 0 Then
        tempAnglea = dblAngle(0) – 20
      Else
        tempAnglea = dblAngle(0) + 20
      End If
      arrNewestPt = Rhino.Polar (arrNewPt, tempAnglea, dblDist)
      strNewCrv = Rhino.addLine (arrNewPt,Array(arrNewestPt(0),arrNewestPt(1),arrNewestPt(2)-2))
      Call LSystem(strNewCrv)
    Next
  End If
End Function

Function Random(nMin, nMax)
  Randomize
  Random = Int((nMax – nMin + 1) * Rnd + nMin)
End Function

 

 

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

_Structural Viability Tweaking

Call Main()
Sub Main()
  Dim i
  Dim arrPoint : arrPoint = Rhino.getPoint
  Dim dblheight : dblHeight = 12
  Dim arrTopPt : arrtopPt = Array(arrPoint(0),arrPoint(1),arrPoint(2)+dblHeight)
  For i = -180 To 179 Step 90
    Dim arrNewPoint : arrNewPoint = Rhino.Polar (arrtopPt, i, 10)
    Dim strCrv : strCrv = Rhino.AddLine (arrtopPt, arrNewPoint)
    Call LSystem(strCrv,arrTopPt(2))
  Next
End Sub

Function LSystem(strCrv,arrheight)
  Dim i, arrNewestPt, strNewCrv, tempAnglea, tempAngleb, intRandom
  Dim arrNewPt : arrNewPt = Rhino.CurveEndPoint (strCrv)
  Dim dblDist : dblDist = Rhino.CurveLength (strCrv)
  Dim dblAngle : dblAngle = Rhino.Angle (Rhino.CurveStartPoint (strCrv), Rhino.CurveEndPoint (strCrv))
  dblDist = dblDist – 1.25
  If arrheight > 0 Then
    intRandom = Random(0, 2)
    For i = 0 To intRandom
      If i Mod 2 = 0 Then
        tempAnglea = dblAngle(0) – 20
      Else
        tempAnglea = dblAngle(0) + 20
      End If
      arrNewestPt = Rhino.Polar (arrNewPt, tempAnglea, dblDist)
      strNewCrv = Rhino.addLine (arrNewPt,Array(arrNewestPt(0),arrNewestPt(1),arrNewestPt(2)-1.5))
      Call LSystem(strNewCrv,arrNewestPt(2)-2)
    Next
  End If
End Function

Function Random(nMin, nMax)
  Randomize
  Random = Int((nMax – nMin + 1) * Rnd + nMin)
End Function

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