本帖最后由 Jorin 于 2013-8-30 11:25 编辑
Ansen在Grasshopper板块帮助解决了椭圆表面上升斜线的问题,原帖如下:
http://bbs.rhino3d.asia/thread-23173-1-1.html
这里按照Ansen的思路,来一个RhinoPython的解决方案:
先上图:
代码在GH参数化控制:
具体的做法大家参考代码:
- import rhinoscriptsyntax as rs
- import math
- def creatEllipses(arrEllipses,trans,count):
- ellipse=rs.AddEllipse(rs.WorldXYPlane(),10,6)
- arrEllipses.append(ellipse)
- translation=trans
- for i in range(count-1):
- 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
- def main():
- arrEllipses=[]
- trans=4
- count=8
- seg=10
- rotate=4
- arrPoints=[]
- radius=0.3
- arrPipes=[]
- arrEllipses=creatEllipses(arrEllipses,trans,count)
- arrEllipses=addEndpointlist(arrEllipses,rotate,count)
- arrPoints=divideEllipses(arrEllipses,seg)
- arrPoints=ToggleListDimension(arrPoints)
- arrCurves=addCurvemine(arrPoints)
- arrPipes=addPipemine(arrCurves,radius)
- if __name__=="__main__":
- main()
复制代码 [/hide]
以上代码稍做修改,就可以放如GHpython中,进行参数化的控制,如图:
|