There is no specific isClosed() method defined for AcDbSpline as there is for
AcDbPolyline. However, in many cases, an AcDbSpline can be closed. Here is a
simple solution to implement a setClosed function for splines. It uses the
getNurbsData() and setNurbsData() AcDbSpline methods. getNurbsData will gather
the information about the spline, including a Boolean closed that indicates if
the spline is closed or not. setNurbsData() takes the same arguments as
getNurbsData(), so only the closed argument will be changed to Adesk::kTrue to
obtain the desired result.
And the same idea can be applied to the .NET Spline.NurbData property.
void setClosed(AcDbSpline *pSpline) { int degree; Adesk::Boolean rational; Adesk::Boolean closed; Adesk::Boolean periodic; AcGePoint3dArray controlPoints; AcGeDoubleArray knots; AcGeDoubleArray weights; double controlPtTol; double knotTol; // get data from the spline pSpline->getNurbsData(degree, rational, closed, periodic, controlPoints, knots, weights, controlPtTol, knotTol); if(closed == Adesk::kTrue) return; // set as closed closed = Adesk::kTrue; // apply data back pSpline->setNurbsData(degree, rational, closed, periodic, controlPoints, knots, weights, controlPtTol, knotTol); }

Leave a Reply