Close

Relief for ODA Team in Ukraine

Learn more
ODA Drawings SDK
Overview of Single-Line Text

Single-line text is a text entity that defines a sequence of alphanumeric letters and various symbols as a geometric figure created from linear and circular segments in a restricted rectangular area and placed in one line on a plane. This geometric figure is used as a string of letters in drawings.

The displacement method is used to draw text as a sequence of segments using a movable pen. The pen can perform linear or circular displacement (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 is applied for each letter of the text string as it forms the text figure.

The single-line text entity stores only codes of letters and associates the text appearance with a text style which defines a font.

The OdDbText class is the single-line text object that represents the interface for accessing a text entity and manipulating its properties. The OdDbTextPtr class is the typified smart pointer to an instance of the single-line text object and is used for storing and passing references to this object.

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


OdDbTextPtr pSText = OdDbText::createObject();

The pseudo-constructor initializes the properties of a new instance using default values. After creation, the new text 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 idSText = pBlock->appendOdDbEntity(pSText);

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

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

The OdDbText class is derived from the OdDbEntity class and inherits the general properties of entities. A pointer to the single-line text object can be converted to an entity object. For example:


OdDbEntityPtr pEntity = pSText;

The single-line text object has the AcDbText class name. To verify an instance, use the isKindOf() and desc() methods. For example:


// Accurate comparing
if(pEntity->isA() == OdDbText::desc())
  odPrintConsoleString(L"\nEntity is the single-line text");

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

See Also

Specific Single-Line Text Properties

Example of Working with the Single-Line Text Object

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