本帖最后由 月之眼 于 2016-9-21 13:07 编辑
给你简单改了一下,快不少,你可以看看- #coding=utf-8
- import rhinoscriptsyntax as rs
- import random
- import Rhino.Geometry as rg
- def ptRange(pt01,pt02):
- xB = random.uniform(pt01[0],pt02[0])
- yB = random.uniform(pt01[1],pt02[1])
- zB = random.uniform(pt01[2],pt02[2])
- return xB,yB,zB
- randomPtsNum = rs.GetInteger("输入生成的随机点数")
- brep = rs.GetObject("选择要生成随机点的多重曲面",rs.filter.polysurface)
- geo_brep = rs.coercebrep(brep)
- box = geo_brep.GetBoundingBox(True)
- random_pt = []
- while (len(random_pt)<= randomPtsNum):
- pt = ptRange(box.Min,box.Max)
- if rs.IsPointInSurface(brep,pt,True,3):
- random_pt.append(pt)
- for pot in random_pt:
- rs.AddPoint(pot)
复制代码
|