Rhino(犀牛)中国技术支持与推广中心

标题: 继续Jorin版大的椭圆上升斜线代码 [打印本页]

作者: yesmely    时间: 2013-9-1 21:29
标题: 继续Jorin版大的椭圆上升斜线代码
本帖最后由 yesmely 于 2013-9-1 21:33 编辑

#感谢Jorin贴出的代码,也引起了本人学习python的兴趣,周末看下论坛的视频,又下载了101翻看,觉得python语言非常容易上手,怪不得MIT改用她作为教学。下面把是轻微调整后的Jo大的代码,并附上了gh文件,希望对跟我一样一头雾水的朋友有帮助,最好结合J大原来的代码看看区别。再次感谢Jorin!
  1. import rhinoscriptsyntax as rs
  2. import math
  3. def creatEllipses(r1,r2,trans,count):
  4.     ellipse = rs.AddEllipse(rs.WorldXYPlane(),r1,r2)
  5.     arrEllipses = []
  6.     arrEllipses.append(ellipse)
  7.     translation = trans
  8.     for i in range(10):
  9.         arrEllipses.append(rs.CopyObject(ellipse,(0,0,translation)))
  10.         translation = translation+trans
  11.     return arrEllipses
  12. def addEndpointlist(arrEllipses,rotate,count):
  13.     p = rotate/count
  14.     s = 0.0
  15.     def remain(x):
  16.         y = math.pi*2
  17.         if x<=y:
  18.             return x
  19.         else:
  20.             x = remain(x-y)
  21.             return x
  22.     for ellipse in arrEllipses:
  23.         rs.CurveSeam(ellipse,remain(s))
  24.         s = s+p
  25.     return arrEllipses
  26. def divideEllipses(arrEllipses,seg):
  27.     arrPoints = []
  28.     for ellipse in arrEllipses:
  29.         points = rs.DivideCurve(ellipse,seg)
  30.         arrPoints.append(points)
  31.     return arrPoints
  32. def ToggleListDimension(inlist):
  33.     return ([ [row[col] for row in inlist] for col in range(len(inlist[0]))])
  34. def addCurvemine (arrPoints):
  35.     arrCurves = []
  36.     for points in arrPoints:
  37.         curve = rs.AddCurve(points)
  38.         arrCurves.append(curve)
  39.     return arrCurves
  40. def addPipemine(arrCurves,radius):
  41.     arrPipes = []
  42.     for curve in arrCurves:
  43.         pipe = rs.AddPipe(curve,0,radius)
  44.         arrPipes.append(pipe[0])
  45.     return arrPipes
  46. #######now beginning#######
  47. temp1 = creatEllipses(r1,r2,trans,count)
  48. temp2 = addEndpointlist(temp1,rotate,count)
  49. temp2 = divideEllipses(temp2,seg)
  50. temp3 = ToggleListDimension(temp2)
  51. temp3 = addCurvemine(temp3)
  52. temp4 = addPipemine(temp3,radius)
  53. Ellipses = temp1
  54. Curves = temp3
  55. Pipes = temp4
复制代码
python upup.rar (14.27 KB, 下载次数: 157)

作者: sunrise10282    时间: 2013-9-2 22:49
谢谢分享 看看ghpython如何修改设置




欢迎光临 Rhino(犀牛)中国技术支持与推广中心 (http://bbs.rhino3d.asia/) Powered by Discuz! X3.2