lsysgengh.gh
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import math
def generate(ptn,angle):
objs = []
stackVecList = []
stackPosList = []
stackRadList = []
v = rg.Vector3d(0,1,0)
p = rg.Point3d(0,0,0)
for i in range(len(ptn)):
if ptn[i] == 'X':
pass#do nothing
elif ptn[i] == 'F':
#here we generate Rhino object
line = rs.AddLine(p,p+v)
objs.append(line)
p = p + v
elif ptn[i] == '+':
rg.Vector3d.Rotate(v,math.radians(angle),rg.Vector3d(0,0,1))
elif ptn[i] == '-':
rg.Vector3d.Rotate(v,math.radians(-angle),rg.Vector3d(0,0,1))
elif ptn[i] == '[':
stackVecList.append(rg.Vector3d(v))#be careful! need stack the copy of vector
stackPosList.append(p)
elif ptn[i] == ']':
v = stackVecList[-1]
p = stackPosList[-1]
stackVecList.pop()
stackPosList.pop()
return objs
#------------------------
a = generate(ptn,ang)
Comments are closed.