|
typedef void (*DoSomethingWithEnt)( AcDbEntity*);
void WalkThrough(AcDbDatabase* db, DoSomethingWithEnt callBack)
{
AcDbBlockTable *pBlockTable;
db->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableIterator* pBlockIt;
Acad::ErrorStatus es = pBlockTable->newIterator(pBlockIt);
if(Acad::eOk != es)
{
pBlockTable->close();
return;
}
AcDbBlockTableRecord *pBlockTableRecord;
for(pBlockIt->start();!pBlockIt->done();pBlockIt->step())
{
es = pBlockIt->getRecord(pBlockTableRecord, AcDb::kForRead);
if(Acad::eOk == es)
{
AcDbBlockTableRecordIterator* pEntIt;
es = pBlockTableRecord->newIterator(pEntIt);
if(Acad::eOk == es)
{
for (pEntIt->start();!pEntIt->done();pEntIt->step())
{
AcDbEntity* pEnt;
es = pEntIt->getEntity(pEnt, AcDb::kForWrite);
if (Acad::eOk == es)
{
callBack(pEnt);
pEnt->close();
}
}
delete pEntIt;
}
pBlockTableRecord->close();
}
}
delete pBlockIt;
pBlockTable->close();
} |
|