您当前的位置: 首页 >  Python

插件开发

暂无认证

  • 1浏览

    0关注

    492博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

犀牛插件-获取曲面表面点-Python-坐标点数组-rhino插件

插件开发 发布时间:2022-04-18 08:15:16 ,浏览量:1

文章目录
    • 1.功能代码
    • 2.作者答疑

1.功能代码

  犀牛软件是一款专业的三维设计软件。简单实用方便,在三维矢量领域有着广泛的用途,开发拓展这款软件的插件,可以方便设计师摆脱一些繁重的重复劳动,有着现实的需求。作者整理了一个python开发的脚本,功能是获取曲面表面点和坐标点数组,作为范例,源代码如下:

# Creates an array of points on a surface
import rhinoscriptsyntax as rs

def ArrayPointsOnSurface():
    # Get the surface object
    surface_id = rs.GetObject("Select surface", rs.filter.surface)
    if surface_id is None: return

    # Get the number of rows
    rows = rs.GetInteger("Number of rows", 2, 2)
    if rows is None: return

    # Get the number of columns
    columns = rs.GetInteger("Number of columns", 2, 2)
    if columns is None: return

    # Get the domain of the surface
    U = rs.SurfaceDomain(surface_id, 0)
    V = rs.SurfaceDomain(surface_id, 1)
    if U is None or V is None: return

    # Add the points
    for i in xrange(0,rows):
        param0 = U[0] + (((U[1] - U[0]) / (rows-1)) * i)
        for j in xrange(0,columns):
            param1 = V[0] + (((V[1] - V[0]) / (columns-1)) * j)
            point = rs.EvaluateSurface(surface_id, param0, param1)
            rs.AddPoint(point)


# Check to see if this file is being executed as the "main" python
# script instead of being used as a module by some other python script
# This allows us to use the module which ever way we want.
if __name__ == "__main__":
    # call the function defined above
    ArrayPointsOnSurface()
2.作者答疑

  如有疑问,请留言。

关注
打赏
1665481431
查看更多评论
立即登录/注册

微信扫码登录

0.0415s