A table is a parametric entity that defines a set of distributed data as rows and columns.
The OdDbTable class is a table object that represents the interface for accessing a table entity and manipulating its properties.
The OdDbTablePtr class is the typified smart pointer to an instance of the table entity and is used for storing and passing references to the table object.
To create an instance of the table object, use the createObject() method of the OdDbTable class which is the static pseudo-constructor. For example:
OdDbTablePtr pTable = OdDbTable::createObject();
The pseudo-constructor initializes the properties of a new instance using default
values. After creation, the new table instance must be added in model space,
paper space, or a block using the appendOdDbEntity() method. The database associates
the object ID with the table instance. In the 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 idTable = pBlock->appendOdDbEntity(pTable);
//Add in model space
OdDbBlockTableRecordPtr pModel = pDb->getModelSpaceId().safeOpenObject(OdDb::kForWrite);
pModel->appendOdDbEntity(pTable);
// Add in the paper space
OdBlockTableRecordPtr pPaper = pDb->getPaperSpaceId().safeOpenObject(OdDb::kForWrite);
pPaper->appendOdDbEntity(pTable);
The OdDbTable class is derived from the OdDbBlockReference class which is derived
from the OdDbEntity class, therefore the OdDbTable class also inherits the general
properties of entities. A pointer to a table object can be converted to an entity
object or a block reference object. For example:
The table object has the AcDbTable class name. To verify an instance, use the isKindOf() and desc() methods. For example:
//Accurate comparing
if (pEntity->isA() == OdDbTable::desc())
wcout << L"\nEntity is the table";
// Check the belonging
if (pEntity->isKindOf(OdDbTable::desc()))
wcout << L"\nEntity is derived from the table";