文章目录
1.程序算法
- 1.程序算法
- 2.作者答疑
犀牛软件是一款专业的三维设计软件。简单实用方便,在三维矢量领域有着广泛的用途,开发拓展这款软件的插件,可以方便设计师摆脱一些繁重的重复劳动,有着现实的需求。作者整理了一个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.作者答疑如有疑问,请留言。