您当前的位置: 首页 >  Python

插件开发

暂无认证

  • 1浏览

    0关注

    492博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

犀牛脚本插件-获取选择对象长度-Python-几何对象长度-rhino脚本

插件开发 发布时间:2022-04-25 07:15:44 ,浏览量:1

文章目录
    • 1.程序算法
    • 2.作者答疑

1.程序算法

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

import rhinoscriptsyntax as rs

def CurveLength():
    "Calculate the length of one or more curves"
    # Get the curve objects
    arrObjects = rs.GetObjects("Select Objects", rs.filter.curve, True, True)
    if( arrObjects==None ): return
    rs.UnselectObjects(arrObjects)

    length = 0.0
    count  = 0
    for object in arrObjects:
        if rs.IsCurve(object):
            #Get the curve length
            length += rs.CurveLength(object)
            count += 1
    
    if (count>0):
        print "Curves selected:", count, " Total Length:", length
    
# 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__" ):
    CurveLength()

  合理的脚本代码可以有效的提高工作效率,减少重复劳动。

2.作者答疑

  如有疑问,请留言。

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

微信扫码登录

0.0373s