2

我想通过 IronPython从RhinoCommonCurve.Trim(CurveEnd, Double) API 调用该方法。我怎样才能确保我没有得到超载?Curve.Trim(Double, Double)

crv.Trim(geo.CurveEnd.End, 8.8)
    #raised: Message: expected float, got CurveEnd

注意:如果您想自己尝试,您需要安装Rhino 的试用版。它包括一个 Python 编辑器。

编辑/添加:杰夫提到 的.Overloads属性在这里也不起作用。用于测试的片段:

import rhinoscriptsyntax as rs
import Rhino.Geometry as geo
import System

# first draw a curve longer than 8.8 units
crvO = rs.GetObject() # to pick that curve on the 3d GUI screen 
crv = rs.coercecurve(crvO)  # to get Rhino.Geometry.Curve

# these both don't work:
crv.Trim(geo.CurveEnd.End, 8.8) 
    #Message: expected float, got CurveEnd

crv.Trim.Overloads[geo.CurveEnd, System.Double](geo.CurveEnd.End, 8.8) 
    #Message: Trim() takes at least 2147483647 arguments (2 given)

rhinscriptsyntax是一个基于RhinoCommon命名空间的库

4

2 回答 2

4

使用该.Overloads属性访问方法的重载:

csv.Trim.Overloads[CurveEnd, float](geo.CurveEnd.End, 8.8)

文档。

于 2013-03-27T19:10:46.860 回答
1

我参加晚会迟到了。但是此代码有效(超出覆盖范围)。

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc
import System

crv_id = rs.GetObject()
crv = rs.coercecurve(crv_id)
trimmed = crv.Trim(Rhino.Geometry.CurveEnd.End, 4)
sc.doc.Objects.Replace(crv_id, trimmed)
sc.doc.Views.Redraw()
于 2019-01-29T18:31:39.250 回答