Rhino.Python脚本创建球体和圆柱

2020-11-11 13:12:04 浏览数 (1)

Talk is cheap,Show me the code:

代码语言:javascript复制
import rhinoscriptsyntax as rs

f = open("coordnates.txt")
line = f.readline()

while line: 
    print(line)
    nums=line.split()
    if(len(nums)==8):
      base=(float(nums[0]),float(nums[1]),float(nums[2]))
      height=(float(nums[3]),float(nums[4]),float(nums[5]))
      radius=float(nums[6])
      rs.AddCylinder( base, height, radius )
    elif(len(nums)==5):
      center=(float(nums[0]),float(nums[1]),float(nums[2]))
      radius=float(nums[3])
      rs.AddSphere(center, radius)
    line = f.readline() 

f.close()

所读取文本文件格式如下:

代码语言:javascript复制
80 50 5 80 50 95 6 0
100 30 5 100 30 95 6 0
50 50 50 8 1

运行结果如下:

颗粒堆积计算效果如下:

0 人点赞