Option Explicit '------------------------------------------------------------------------------------------- 'a simple fractal branching algorithm 'Pablo Miranda Carranza, code released under GNU General Public License (www.gnu.org/licenses/gpl.txt) '------------------------------------------------------------------------------------------- private pi pi = 3.1415926535897932384626433832795 sub main() dim arr_stpt dim arr_endpt arr_stpt=array(0,0,0) arr_endpt=array(0,0,2) Rhino.AddLine arr_stpt, arr_endpt fract_branch arr_endpt,0,10, 10 end sub 'I made this a function that does not return any value...it is for all purposes a subrutine, 'just to show that this also perfectly possible 'It takes as its arguments(input) a starting point (st_pt) a length of the branch (b_length) and the recursion level. 'Observe the 'byval' word...variables in most languages can be passed by value (like here) or by reference, which is the default mode. 'passing 'byval' won't affect the original value (we can add, divide...etc, without the original value been updated) this is not the case 'normally...google byval or byref if you want to understand this in more depth function fract_branch (st_pt,angle,b_length, byval level) Dim newpt1 Dim newpt2 Dim angle1 Dim angle2 level=level-1 angle1=angle+pi/6 angle2=angle-pi/6 newpt1=array(st_pt(0),st_pt(1)+cos(angle1)*b_length,st_pt(2)+sin(angle1)*b_length) newpt2=array(st_pt(0),st_pt(1)+cos(angle2)*b_length,st_pt(2)+sin(angle2)*b_length) Rhino.AddLine st_pt, newpt1 Rhino.AddLine st_pt, newpt2 'recursive call if level>0 then fract_branch newpt1,angle1,b_length*0.9,level fract_branch newpt2,angle2,b_length*0.9,level end if end function main