本帖最后由 yesmely 于 2013-9-1 21:33 编辑
#感谢Jorin贴出的代码,也引起了本人学习python的兴趣,周末看下论坛的视频,又下载了101翻看,觉得python语言非常容易上手,怪不得MIT改用她作为教学。下面把是轻微调整后的Jo大的代码,并附上了gh文件,希望对跟我一样一头雾水的朋友有帮助,最好结合J大原来的代码看看区别。再次感谢Jorin!
- import rhinoscriptsyntax as rs
- import math
- def creatEllipses(r1,r2,trans,count):
- ellipse = rs.AddEllipse(rs.WorldXYPlane(),r1,r2)
- arrEllipses = []
- arrEllipses.append(ellipse)
- translation = trans
- for i in range(10):
- arrEllipses.append(rs.CopyObject(ellipse,(0,0,translation)))
- translation = translation+trans
- return arrEllipses
- def addEndpointlist(arrEllipses,rotate,count):
- p = rotate/count
- s = 0.0
- def remain(x):
- y = math.pi*2
- if x<=y:
- return x
- else:
- x = remain(x-y)
- return x
- for ellipse in arrEllipses:
- rs.CurveSeam(ellipse,remain(s))
- s = s+p
- return arrEllipses
- def divideEllipses(arrEllipses,seg):
- arrPoints = []
- for ellipse in arrEllipses:
- points = rs.DivideCurve(ellipse,seg)
- arrPoints.append(points)
- return arrPoints
- def ToggleListDimension(inlist):
- return ([ [row[col] for row in inlist] for col in range(len(inlist[0]))])
- def addCurvemine (arrPoints):
- arrCurves = []
- for points in arrPoints:
- curve = rs.AddCurve(points)
- arrCurves.append(curve)
- return arrCurves
- def addPipemine(arrCurves,radius):
- arrPipes = []
- for curve in arrCurves:
- pipe = rs.AddPipe(curve,0,radius)
- arrPipes.append(pipe[0])
- return arrPipes
- #######now beginning#######
- temp1 = creatEllipses(r1,r2,trans,count)
- temp2 = addEndpointlist(temp1,rotate,count)
- temp2 = divideEllipses(temp2,seg)
- temp3 = ToggleListDimension(temp2)
- temp3 = addCurvemine(temp3)
- temp4 = addPipemine(temp3,radius)
- Ellipses = temp1
- Curves = temp3
- Pipes = temp4
复制代码
python upup.rar
(14.27 KB, 下载次数: 161)
|