To iterate over all of the entities in a block (for example, model space), you can use code like this:
OdDbObjectId blockId = pDb->getModelSpaceId();
OdDbBlockTableRecordPtr pBlockRecord = blockId.safeOpenObject(OdDb::kForWrite);
OdDbObjectIteratorPtr pIter = pBlockRecord->newIterator();
for (; !pIter->done(); pIter->step())
{
OdDbObjectId objectId = pIter->objectId();
OdDbEntityPtr pEntity = objectId.safeOpenObject(OdDb::kForWrite);
//work with pEntity
}
If you only need to get information from entities without modifying them, you should use OdDb::kForRead when opening the block and its entities.
You can learn more about structure of an OdDbDatabase and records in our documentation: