还是个RhinoCommon 问题

选择一条曲线,怎么找到它的knots点,并转为point3d.
@KelvinC

Hi @dale,

@mdjcad would like to know how to extract the knots from a curve as 3d points. What function can he use? Do you have an example code? Thanks.

@KelvinC
我开始表达有问题。
正确的是,我想找到一条曲线的EditPt,就是 EditPtOn 命令显示的点,想获得这些点的 Point3d 值。我在英文版也有发,不知表达对不对。 :pensive:
http://discourse.mcneel.com/t/how-to-get-point3d-of-knots-on-an-curve/19654

你的問題表答沒問題。

以下是 Dale 的回覆,不過他回答的的是 Knot,不是 Edit Point。

Hi Kelvin,

Not all types of curves have knots, such as lines, polylines, circles, and arcs. Of course, they can be represented as NURBS.

Anyway, to get the knots of a NURBS curve, use Rhino.Geometry.NurbsCurve.Knots. Here is a RhinoCommon, C#, example:


protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
ObjRef obj_ref;
var rc = RhinoGet.GetOneObject(
“Select NURBS curve”,
false, ObjectType.Curve,
out obj_ref
);

if (rc != Result.Success)
return rc;

var nc = obj_ref.Curve() as NurbsCurve;
if (null == nc)
{
RhinoApp.WriteLine(“Not a NURBS curve.”);
return Result.Nothing;
}

for (var i = 0; i < nc.Knots.Count; i++)
RhinoApp.WriteLine(“Knot {0} = {1}”, i, nc.Knots[i]);

return Result.Success;
}

– Dale

Dale Fugier
Rhinoceros Development
Robert McNeel & Associates

@KelvinC
谢谢你,英文版有人回答了edit point问题。