import rhinoscriptsyntax as rs import Rhino.Geometry as rg rs.EnableRedraw(False) origin = rg.Point3d(0,0,0) length = 100 angle = 30 reduction_factor = 0.8 iterations = 8 branches = [] current_iteration = [] next_iteration = [] start_point = origin end_point = start_point + rg.Vector3d.YAxis*length branch = rs.AddLine(start_point, end_point) current_iteration.append(branch) for i in range(iterations): for branch in current_iteration: start_point = rs.CurveEndPoint(branch) length = rs.CurveLength(branch)*reduction_factor axis = rs.VectorCreate(rs.CurveEndPoint(branch), rs.CurveStartPoint(branch)) axis_unitized = axis/rs.CurveLength(branch) end_point = start_point + axis_unitized*length branch_a = rs.AddLine(start_point, end_point) branch_b = rs.AddLine(start_point, end_point) rs.RotateObject(branch_a, start_point, angle) rs.RotateObject(branch_b, start_point, -angle) next_iteration.append(branch_a) next_iteration.append(branch_b) current_iteration = next_iteration next_iteration = []