Rhino(犀牛)中国技术支持与推广中心
标题:
继续Jorin版大的椭圆上升斜线代码
[打印本页]
作者:
yesmely
时间:
2013-9-1 21:29
标题:
继续Jorin版大的椭圆上升斜线代码
本帖最后由 yesmely 于 2013-9-1 21:33 编辑
#感谢Jorin贴出的代码,也引起了本人学习python的兴趣,周末看下论坛的视频,又下载了101翻看,觉得python语言非常容易上手,怪不得MIT改用她作为教学。下面把是轻微调整后的Jo大的代码,并附上了gh文件,希望对跟我一样一头雾水的朋友有帮助,最好结合J大原来的代码看看区别。再次感谢Jorin!
up ok.png
(38.26 KB, 下载次数: 17)
下载附件
2013-9-1 21:32 上传
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, 下载次数: 157)
2013-9-1 21:29 上传
点击文件名下载附件
作者:
sunrise10282
时间:
2013-9-2 22:49
谢谢分享 看看ghpython如何修改设置
欢迎光临 Rhino(犀牛)中国技术支持与推广中心 (http://bbs.rhino3d.asia/)
Powered by Discuz! X3.2