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

A shape is a textual entity that defines a geometric figure created from linear and circular segments in a restricted rectangular area on a plane. A shape is used as a symbol for various implementations, for example, marks on a package, an element of a circuit board, inclusion of linetypes, etc.

The displacement method is used, which draws a shape as a sequence of segments using a movable pen. The pen can perform linear or circular displacement (or shift) plotting of a line or arc. The pen can draw while turned on or off, which performs plotting or only movement. The sequence of such displacements forms the shape figure.

The OdDbShape class is the shape object that represents the interface for accessing a shape entity and manipulating its properties. The OdDbShapePtr class is the typified smart pointer to an instance of the shape object and is used for storing and passing references to this object.

To create an instance of the shape object, use the createObject() method of the OdDbShape class which is the static pseudo-constructor. For example:


OdDbShapePtr pShape = OdDbShape::createObject();

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

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

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

The OdDbShape class is derived from the OdDbEntity class and inherits the general properties of entities. A pointer to a shape object can be converted to an entity object. For example:


OdDbEntityPtr pEntity = pShape;

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


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

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

See Also

Specific Shape Properties

Example of Working with the Shape Object

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