各位大神好:
发个按照最短距离给曲线编号的小脚本,由于写代码我都是自学的,所以难免会有很多常识性的错误,希望各位大神不要笑我哦,请多多指教
#coding=utf-8
import rhinoscriptsyntax as rs
def panduan(curve, lines,i):
if len(lines) == 0:
return
else:
ds = rs.CurveClosestObject(curve, lines)
poi = rs.CurveStartPoint(ds[0])
rs.AddTextDot(i,poi)
lines.remove(ds[0])
panduan(curve,lines,i+1)
if( __name__ == "__main__" ):
poi = rs.GetPoint("拾取一个点")
rs.AddPoint(poi)
lines = rs.GetObjects("选取要编号的曲线",rs.filter.curve)
curve = rs.AddCircle(poi,0.01)
panduan(curve,lines,0)
rs.DeleteObject(curve)
|