here is an ARX version, probably not any faster since IO is the time consuming item.
static void ArxBlockEx_doit(void)
{
clock_t start, end;
double diff;
start = clock();
for(int i = 0 ; i < 500; i++)
{
std::auto_ptr<AcDbDatabase> pDb (new AcDbDatabase(false , true));
pDb->readDwgFile(_T("C:\\Test20090823.dwg"), _SH_DENYNO ,false);
GetAttributesBench_doit(&(*pDb), _T("BBL_V8"));
pDb->closeInput(true);
}
end = clock();
diff = ((double)(end - start)) / CLOCKS_PER_SEC;
acutPrintf( _T("\n%2.3f seconds\n"), diff);
}
static void GetAttributesBench_doit(AcDbDatabase *pDatabase, const CString &name)
{
Acad::ErrorStatus es;
std::wofstream out(_T("C:\\Test20090823.txt"));
AcDbBlockTablePointer pBlockTable(pDatabase,AcDb::kForRead);
if(pBlockTable.openStatus() != eOk) return;
if(!pBlockTable->has(name)) return;
AcDbObjectId blkid;
if(pBlockTable->getAt(name,blkid) != eOk) return;
AcDbBlockTableRecordPointer pTableRecord(blkid,AcDb::kForRead);
if(pTableRecord.openStatus() != eOk) return;
if (pTableRecord->hasAttributeDefinitions() == Adesk::kTrue)
{
AcDbObjectIdArray blockReferenceIds;
pTableRecord->getBlockReferenceIds(blockReferenceIds);
for(int i = 0 ; i < blockReferenceIds.length() ; i++)
{
AcDbObjectPointer<AcDbBlockReference> pBlockReference
(blockReferenceIds[i] , AcDb::kForRead,Adesk::kFalse);
out << "\n";
std::auto_ptr<AcDbObjectIterator>
pAttributeIterator(pBlockReference->attributeIterator());
for (pAttributeIterator->start();
!pAttributeIterator->done();
pAttributeIterator->step())
{
AcDbObjectPointer<AcDbAttribute> pAttribute
(pAttributeIterator->objectId(),AcDb::kForRead);
if(pAttribute.openStatus() == eOk)
out << "("<< pAttribute->tag() << "." << pAttribute->textString() << ")";
}
}
}
out.close();
}