给你一段代码吧 希望对你有启发 AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase(); if (pDb == NULL) { acutPrintf("\n当前无活动的图形!"); return false; } AcDbBlockTable *pBlockTable; if (pDb->getBlockTable(pBlockTable, AcDb::kForRead) != Acad::eOk) { acutPrintf("\n打开块表失败!"); return false; } AcDbBlockTableRecord *pBlockRec; if (pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockRec, AcDb::kForRead)!= Acad::eOk) { acutPrintf("打开模型空间失败!"); pBlockTable->close(); return false; } pBlockTable->close(); AcDbBlockTableRecordIterator* pIterator,*pIter; pBlockRec->newIterator(pIterator,true,false); pBlockRec->newIterator(pIter,true,false); if( pIterator->done()) { acutPrintf("\n当前图形无数据。"); pBlockRec->close(); delete pIterator; return false; } AcDbEntity* pEnt; for(; !pIterator->done(); pIterator->step(true,false)) { if(pIterator->getEntity(pEnt, AcDb::kForRead,true)!=Acad::eOk) continue; if(pEnt->isKindOf(AcdbText::desc() true) { AcDbObjectId eId; eId=pEnt->objectId(); ids.append(eId); } pEnt->close(); } pBlockRec->close(); delete pIterator; |