I have two questions about On_BezierCurve
1:
I can’t find a function GetLenth in ON_BezierCurve Class,but ON_NurbsCurve Class Has this function
2: I Use next codes first Creat a ON_BezierCurve ,than convert to ON_NurbsCurve,but I find the len of the curve is zero.in fact ,I add the curve to the scene,the curve is not looks like normal
ON_BezierCurve bc(ps);
ON_NurbsCurve*nc=new ON_NurbsCurve(bc);
double len;
nc->GetLenth(&len);
attachment have a test plugin and a 3d fileON_BezierCurve.rar (11.2 MB)
Yes very strange. After the curve is added to the document, the Length command gives the correct length, but in the command the length is always zero (even when using less strict fractional tolerance values).
This looks like a bug to me. Maybe @dale can help here to solve this.
If you look in opennurbs_nurbscurve.h
, you will see this comment:
Use ON_NurbsCurve::New(…) instead of new ON_NurbsCurve(…)
Thus, your code should look like this:
ON_NurbsCurve* nurb = ON_NurbsCurve::New(bezier);
Creating one on the stack like this will also work:
ON_NurbsCurve nurb(bezier);
Does this help?
– Dale
I tried bc.GetNurbForm on an ON_NurbsCurve on the stack: same problem…
Yes, this is somewhat odd. I’ve added a YouTrack item to (hopefully) address this in Rhino 6.
In the mean time, you can use a function like this:
double ON_NurbsCurveLength(const ON_NurbsCurve& nc)
{
double length = ON_UNSET_VALUE;
if (nc.IsValid())
{
if (!nc.GetLength(&length))
{
ON_MassProperties mp;
if (nc.LengthMassProperties(mp, true, false, false, false))
length = fabs(mp.m_mass);
}
}
return length;
}
Does this help?
thanks ,dale ,menno