Drawings SDK Developer Guide > Working with .dwg Files > Working with Entities > Working with Specific Entitites > Working with Ellipses > Overview of Ellipses
Overview of Ellipses

An ellipse is a parametric entity that specifies a closed or unclosed elliptical figure in world space. The OdDbEllipse class is the ellipse object that represents the interface for accessing a closed ellipse entity and elliptical arc entity, and for manipulating their properties. The OdDbEllipsePtr class is the typified smart pointer to an instance of the closed ellipse entity or elliptical arc entity, and is used for storing and passing references to the ellipse object.

To create an instance of the ellipse object, use the createObject() method of the OdDbEllipse class that is the static pseudo-constructor. For example:


OdDbEllipsePtr pEllipse = OdDbEllipse::createObject();

The pseudo-constructor initializes the properties of a new instance using default values. After creating, the new ellipse instance must be added in model space, paper space, or a block using the appendOdDbEntity() method. The database associates the object ID with the ellipse instance. In 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 idEllipse = pBlock->appendOdDbEntity(pEllipse);

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

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

The OdDbEllipse 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 OdDbCircle class also inherits the general properties of entities. A pointer to an ellipse object can be converted to an entity object or a curve object. For example:


OdDbEntityPtr pEntity = pEllipse;
OdDbCurvePtr pCurve = pEllipse;

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


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

// Check on belonging
if(pEntity->isKindOf(OdDbEllipse::desc()))
  odPrintConsoleString(L"\nEntity is derived from the ellipse object");

See Also

Specific Ellipse Properties

Computed Ellipse and Elliptical Arc Properties

Example of Working with the Ellipse Object

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