OnNurbsCurve to NurbsCurve best way?


#1

So we are starting to use RhinoCommon as our default programming sdk
But still have lots of .net sdk code.

So my question is:
I have an OnNurbsCurve and I want to get it to a RhinoCommon NurbsCurve

I can use:

    OnNurbsCurve onc = MyFunctionToGetOnNurbsCurve();
    Curve c = Interop.FromOnCurve(onc);
    NurbsCurve nc = c.ToNurbsCurve();

But it would be nice to skip the middle step of the Curve.

I am really looking for something like:
NurbsCurve nc = Interop.FromOnNurbscurve(onc);

Or is what I have about as good as it is going to get?

Thanks

Gordon J.


(Dale Fugier) #2

I would think that, in the case of NURBS curves, this:

OnNurbsCurve onc = MyFunctionToGetOnNurbsCurve();
Curve c = Interop.FromOnCurve(onc);
NurbsCurve nc = c.ToNurbsCurve();

and this:

OnNurbsCurve onc = MyFunctionToGetOnNurbsCurve();
NurbsCurve nc = Interop.FromOnCurve(onc) as NurbsCurve;

would produce the same results, being that c is a NURBS curve. Have you tried?


#3

Thank You Dale.

The ‘as NurbsCurve’ work as you suggested.

Thanks Again
Gordon.