# GetLength on Bezier Curve

Hi there, was just trying to get the length of a bezier curve inside a VB.net GH component. I convert it first to NurbsCurve but it always returns 0. If I output the curve and use the built in GH curve length component it works fine. Here’s the code I’m using, am I doing something wrong? Thank you!

``````    Dim pt(3) As Point3d
pt(0) = New Point3d(0, 0, 0)
pt(1) = New Point3d(1, 0, 0)
pt(2) = New Point3d(1, 2, 0)
pt(3) = New Point3d(2, 2, 0)

Dim bez As New beziercurve(pt)
Dim crv As Nurbscurve = Nothing
crv = bez.ToNurbsCurve
Print(crv.GetLength())

A = crv
``````

That looks like a bug to me. If I call `bez.ToNurbsCurve().ToNurbsCurve()` the length is not zero. One call (`bez.ToNurbsCurve()`) and the curve has zero length.

@dale could you take a look at this?

My C# code, tested in a Rhino command:

``````Point3d[] pt = new Point3d[4];
pt[0] = new Point3d(0, 0, 0);
pt[1] = new Point3d(1, 0, 0);
pt[2] = new Point3d(1, 2, 0);
pt[3] = new Point3d(2, 2, 0);

BezierCurve bez = new BezierCurve(pt);
NurbsCurve crv = bez.ToNurbsCurve(); // first call to .ToNurbsCurve()

RhinoApp.WriteLine("1. Bezier curve length {0}", crv.GetLength()); // output zero

crv = crv.ToNurbsCurve(); // second call to .ToNurbsCurve()

RhinoApp.WriteLine("2. Bezier curve length {0}", crv.GetLength()); // output non-zero

var obj = doc.Objects.Find(crvId);
var crvFromDoc = obj.Geometry as Curve;

if (null != crvFromDoc)
RhinoApp.WriteLine("Curve from doc length {0}", crvFromDoc.GetLength());

return Result.Success;

``````

Hi @Steven, @menno: I have confirmed this is a bug - thanks for reporting and our apologies for any inconvenience.

I am fixing the bug in the WIP, but I am unsure it will make it into this week’s release. If not, it will definitely appear in next week’s release.

https://mcneel.myjetbrains.com/youtrack/issue/RH-40480

– Dale

1 Like

Thanks guys!

hi, how can i do this script into the vb.net in grasshopper?

Do what? Can you describe in more detail what you want to do or what problem you are trying to solve? Feel free to provide sample models or GH files if that helps describe your problem.

Thanks,

– Dale

I am trying to draw a bezier curve via vb.net in grasshopper.
Thanks from now.