Close

Relief for ODA Team in Ukraine

Learn more
ODA Drawings SDK
Overview of Lightweight Polylines

A lightweight polyline is a parametric entity that specifies a set of straight and arc segments of different widths connected in a single curve in a plane. The OdDbPolyline class is a polyline object that represents an interface for accessing a lightweight polyline entity and manipulating its properties. The OdDbPolylinePtr class is the typified smart pointer to an instance of the polyline entity and is used for storing and passing references to the lightweight polyline object.

In comparison to a regular two-dimensional polyline represented by the OdDb2dPolyline class, a lightweight polyline uses resources more efficiently. A lightweight polyline is stored in a database as a single entity while a regular polyline stores every vertex as a separate entity inside the internal entity container. Therefore, a lightweight polyline is more efficient in memory usage and allows for higher performance because there is no need to spend additional computing resources on processing every vertex entity. However, the functionality of a lightweight polyline is reduced slightly compared to a regular polyline. A lightweight polyline's segments can still have their own properties for width (constant or variable) and bulge, but a lightweight polyline does not support curve and spline fitting.

To create an instance of the lightweight polyline, use the createObject() method of the OdDbPolyline class that is the static pseudo-constructor. For example:


OdDbPolylinePtr pLWPL = OdDbPolyline::createObject();

The pseudo-constructor initializes the properties of a new instance using default values. After creating it, a new instance must be added in model space, paper space, or a block using the appendOdDbEntity() method. The database associates the object ID with the lightweight polyline instance. In the following examples, the pDb variable stores a pointer to the database object. For example:


// Add in the block
OdDbBlockTablePtr pBlocks = pDb->getBlockTableId().safeOpenObject(OdDb::kForRead);
OdDbBlockTableRecordPtr pBlock = pBlocks->getAt(L"BLOCK", OdDb::kForWrite)
OdDbObjectId idLine = pBlock->appendOdDbEntity(pLWPL);

// Add in the model space
OdDbBlockTableRecordPtr pModel = pDb->getModelSpaceId().safeOpenObject(OdDb::kForWrite);
pModel->appendOdDbEntity(pLWPL);

// Add in the paper space
OdDbBlockTableRecordPtr pPaper = pDb->getPaperSpaceId().safeOpenObject(OdDb::kForWrite);
pPaper->appendOdDbEntity(pLWPL);

The OdDbPolyline class is derived from the OdDbCurve class and inherits the common properties of parametric curves. The OdDbCurve class is derived from the OdDbEntity class, therefore the OdDbPolyline class also inherits the general properties of entities. A pointer to a lightweight polyline object can be converted to an entity object or a curve object. For example:


OdDbEntityPtr pEntity = pLWPL;
OdDbCurvePtr pCurve = pLWPL;

The lightweight polyline object has the AcDbPolyline class name. To verify an instance, use the isKindOf() and desc() methods. For example:


// Accurate comparing
if(pEntity->isA() == OdDbPolyline::desc())
  odPrintConsoleString(L"\nEntity is the lightweight polyline");

// Check on belonging
if(pEntity->isKindOf(OdDbPolyline::desc()))
  odPrintConsoleString(L"\nEntity is derived from lightweight polyline");

See Also

Working with Lightweight Polylines

Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.