Curve Functions

The abstract base class AcDbCurve provides a number of functions for operating on curves, including functions for projecting, extending, and offsetting curves, as well as a set of functions for querying curve parameters. Curves can be defined either in parameter space or in Cartesian coordinate space. A 3D curve is a function of one parameter (f(t)), while a 3D surface is a function of two parameters (f(u,v)). Conversion functions allow you to convert data from its parameter representation to points in the Cartesian coordinate system. Splines, for example, are best represented in parameter space. To split a spline into three equal parts, you first find the parameters that correspond to the points of the spline and then operate on the spline in parameter space. Curves can be used as trim boundaries, extension boundaries, and as construction objects for creating complex 3D entities.

You can project a curve onto a plane in a given direction, as shown in the following example.

// Accepts an ellipse object ID, opens the ellipse, and uses
// its getOrthoProjectedCurve member function to create a
// new ellipse that is the result of a projection onto the
// plane with normal <1,1,1>.  The resulting ellipse is
// added to the model space block table record.
//
void
projectEllipse(AcDbObjectId ellipseId)
{
    AcDbEllipse *pEllipse;
    acdbOpenObject(pEllipse, ellipseId, AcDb::kForRead);
    // Now project the ellipse onto a plane with a
    // normal of <1, 1, 1>.
    //
    AcDbEllipse *pProjectedCurve;
    pEllipse->getOrthoProjectedCurve(AcGePlane(
        AcGePoint3d::kOrigin, AcGeVector3d(1, 1, 1)),
        (AcDbCurve*&)pProjectedCurve);
    pEllipse->close();
    AcDbObjectId newCurveId;
    addToModelSpace(newCurveId, pProjectedCurve);
}
// Accepts an ellipse object ID, opens the ellipse, and uses
// its getOffsetCurves() member function to create a new
// ellipse that is offset 0.5 drawing units from the
// original ellipse.
//
void
offsetEllipse(AcDbObjectId ellipseId)
{
    AcDbEllipse *pEllipse;
    acdbOpenObject(pEllipse, ellipseId, AcDb::kForRead);
    // Now generate an ellipse offset by 0.5 drawing units.
    //
    AcDbVoidPtrArray curves;
    pEllipse->getOffsetCurves(0.5, curves);
    pEllipse->close();
    AcDbObjectId newCurveId;
    addToModelSpace(newCurveId, (AcDbEntity*)curves[0]);
}