static void swtArxProject5readdwg(void) { // Add your code for command swtArxProject5.readdwg here //打开测试文件test.dwg AcDbDatabase *pDb=new AcDbDatabase(Adesk::kFalse); pDb->readDwgFile(_T("c:/test.dwg")); //获取块表 AcDbBlockTable *pBlkTbl; pDb->getSymbolTable(pBlkTbl,AcDb::kForRead); //获取块表记录 AcDbBlockTableRecord *pBlkRcd; pBlkTbl->getAt(ACDB_MODEL_SPACE,pBlkRcd,AcDb::kForWrite); pBlkTbl->close(); //建立迭代器准备进行循环 AcDbBlockTableRecordIterator *pBlkTblRcdltr; pBlkRcd->newIterator(pBlkTblRcdltr); //定义实体指针 AcDbEntity *pEnt; //在读入的块表记录中进行迭代 for (pBlkTblRcdltr->start();!pBlkTblRcdltr->done();pBlkTblRcdltr->step()) { //读取实体 pBlkTblRcdltr->getEntity(pEnt,AcDb::kForRead); //pEnt=pBlkTblRcdltr->getEntity(AcDb::kForRead); //获取实体类型 acutPrintf(_T(" 实体类型:%s"),pEnt->isA()->name()); //关闭实体指针 pEnt->close(); } //关闭块表 pBlkRcd->close(); //删除块表记录迭代器 delete pBlkTblRcdltr; //删除图形 delete pDb; }