Array Points on Surface

桃扇骨 2022-06-14 07:38 233阅读 0赞

这里写图片描述

  1. # Creates an array of points on a surface
  2. import rhinoscriptsyntax as rs
  3. def ArrayPointsOnSurface():
  4. # Get the surface object
  5. surface_id = rs.GetObject("Select surface", rs.filter.surface)
  6. if surface_id is None: return
  7. # Get the number of rows
  8. rows = rs.GetInteger("Number of rows", 2, 2)
  9. if rows is None: return
  10. # Get the number of columns
  11. columns = rs.GetInteger("Number of columns", 2, 2)
  12. if columns is None: return
  13. # Get the domain of the surface
  14. U = rs.SurfaceDomain(surface_id, 0)
  15. V = rs.SurfaceDomain(surface_id, 1)
  16. if U is None or V is None: return
  17. # Add the points
  18. for i in xrange(0,rows):
  19. param0 = U[0] + (((U[1] - U[0]) / (rows-1)) * i)
  20. for j in xrange(0,columns):
  21. param1 = V[0] + (((V[1] - V[0]) / (columns-1)) * j)
  22. point = rs.EvaluateSurface(surface_id, param0, param1)
  23. rs.AddPoint(point)
  24. # Check to see if this file is being executed as the "main" python
  25. # script instead of being used as a module by some other python script
  26. # This allows us to use the module which ever way we want.
  27. if __name__ == "__main__":
  28. # call the function defined above
  29. ArrayPointsOnSurface()

发表评论

表情:
评论列表 (有 0 条评论,233人围观)

还没有评论,来说两句吧...

相关阅读