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

A trace is an entity that specifies a quadrangle planar figure in world space. The OdDbTrace class is a trace object that represents the interface for accessing a trace entity and manipulating its properties. The OdDbTracePtr class is the typified smart pointer to an instance of the trace entity and is used for storing and passing references to the trace object.

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


OdDbTracePtr pTrace = OdDbTrace::createObject();

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

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

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

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


OdDbEntityPtr pEntity = pTrace;

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


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

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

See Also

Specific Trace Properties

Example of Working with the Trace Object

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