Option Explicit 'Script written by Luis Gil 'This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. 'To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0 'www.legildesign.com Public blnScale Public dblScaleFactor Call Main() Sub Main() Dim strCrv strCrv = Rhino.GetObject("Select origin curve.", 4) If IsNull(strCrv) Then Exit Sub Dim intLimit intLimit = Rhino.GetInteger("Input number of branches.", 5, 1, 30) If IsNull(intLimit) Then Exit Sub Dim dblAngle dblAngle = Rhino.GetReal("Input branch angle.", 10, 1, 90) If IsNull(dblAngle) Then Exit Sub blnScale = Rhino.GetBoolean("Diminish branch length?", Array("Diminish", "No", "Yes"), Array(False)) If IsNull(blnScale) Then Exit Sub If blnScale(0) Then dblScaleFactor = Rhino.GetReal("Diminishing factor for each branch order?", 0.9) If IsNull(dblScaleFactor) Then Exit Sub End If Dim blnWatch blnWatch = Rhino.GetBoolean("Watch growth?", Array("Watch", "No", "Yes"), Array(False)) If IsNull(blnWatch) Then Exit Sub Dim arrCrvs(0) arrCrvs(0) = strCrv If Not(blnWatch(0)) Then Call Rhino.EnableRedraw(False) End If Call GrowTree(arrCrvs, dblAngle, intLimit,1) If Not(blnWatch(0)) Then Call Rhino.EnableRedraw(True) End If End Sub Sub GrowTree(arrCrvs, dblAngle, intLimit, intID) If intID > intLimit Then Exit Sub Rhino.Print "Branch " & intId Dim arrNewCrvs() Dim index : index = -1 Dim l For Each l In arrCrvs Dim startPt, endPt startPt = Rhino.CurveStartPoint(l) endPt = Rhino.CurveEndPoint(l) Dim newCrv1, newCrv2 newCrv1 = Rhino.CopyObject(l,startPt,endPt) newCrv2 = Rhino.CopyObject(l, startPt,endPt) newCrv1 = Rhino.RotateObject(newCrv1, endPt, dblAngle) newCrv2 = Rhino.RotateObject(newCrv2, endPt, -dblAngle) If blnScale(0) Then newCrv1 = Rhino.ScaleObject(newCrv1, endPt, Array(dblScaleFactor, dblScaleFactor,1)) newCrv2 = Rhino.ScaleObject(newCrv2, endPt, Array(dblScaleFactor, dblScaleFactor, 1)) End If index = index +2 ReDim Preserve arrNewCrvs(index) arrNewCrvs(UBound(arrNewCrvs) -1) = newCrv1 arrNewCrvs(UBound(arrNewCrvs)) = newCrv2 Next Dim intNewId : intNewId = intID + 1 Call GrowTree(arrNewCrvs, dblAngle, intLimit, intNewId) End Sub