本着模块化思路,按照雪花的框架:http://bbs.rhino3d.asia/thread-23244-1-1.html
稍作修改,即可。
代码如下:- import rhinoscriptsyntax as rs
- def tree1(geo,ang,sc):
- ptlist=rs.DivideCurve(geo,1,False,True)
- pt0=ptlist[0]
- pt1=ptlist[1]
- vec=rs.VectorCreate(pt1,pt0)
- ptsc=rs.VectorScale(vec,sc)
- pti=pt0+ptsc
- line0=rs.AddLine(pt1,pti)
- left=rs.RotateObject(line0,pt1,ang,None,False)
- right=rs.RotateObject(left,pt1,-2*ang,None,True)
- return [left,right]
- def trees(geos,ang,sc):
- list=[]
- for x in geos:
- for y in tree1(x,ang,sc):
- list.append(y)
- return list
- def tree(geo,ang,deg,sc):
- if deg==0:
- return geo
- elif deg==1:
- return tree1(geo,ang,sc)
- else:
- return trees(tree(geo,ang,deg-1,sc),ang,sc)
- geo=rs.GetObject("Select a line:")
- ang=rs.GetInteger("Angle=")
- deg=rs.GetInteger("Degree=")
- sc=rs.GetReal("bigger scale number=")
- tree(geo,ang=30,deg=5,sc=1.7)
复制代码 通过这两个小例子,能够看出第一个def是核心,只要改动这里能得到更多的形式。未完。 |