Jorin 发表于 2014-2-19 17:31
把我那段代码改了改,放到你的GH里面,就是这个样子了。
改的时候用了一个全局变量。
给Jorin大神交个作业:这是我把原来那个改好了、、嘿嘿
import rhinoscriptsyntax as rs
def main():
global new_lines
new_lines = []
snow(line,0,new_lines)
def snow(line,level,new):
if level == maxlevel:
new.append(line)
return
start = rs.CurveStartPoint(line)
end = rs.CurveEndPoint(line)
pt1 = start*(2/3) + end*(1/3)
pt2 = start*(1/3) + end*(2/3)
midv = (start + end)/2
mid = rs.AddPoint(midv)
vector = rs.VectorCreate(end,start)
vector = rs.VectorCrossProduct(vector,[0,0,1])
vector = rs.VectorUnitize(vector)
vector = rs.Distance(pt1,pt2)*num*vector
mid = rs.MoveObject(mid,vector)
level += 1
snow(rs.AddLine(start,pt1),level,new)
snow(rs.AddLine(pt1,mid),level,new)
snow(rs.AddLine(mid,pt2),level,new)
snow(rs.AddLine(pt2,end),level,new)
main()
|