- 积分
- 937
- 明经币
- 个
- 注册时间
- 2004-12-30
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
摘自《AutoCAD ObjectARX2000开发技术指南》
我们用下面的例子说明如何使用块表记录遍历器遍历块表记录,并在屏幕上打印出块中所含对象的信息。 程序中用printAll()函数打开一个块表进行读操作,然后根据用户提供的块名打开块表记录,使用一个新块表记录遍历器遍历块表记录。如果记录中含有实体,则遍历器打印出该实体的信息 void printAll() { int rc; char blkName[50]; rc = acedGetString(Adesk::kTrue, "请输入块名<回车取回当前空间块名>:", blkName); if(rc!=RTNORM) return; if(blkName[0]=='\0'){ if(acdbHostApplicationServices()->workingDatabase() ->tilemode() == Adesk::kFalse){ struct resbuf rb; acedGetVar("cvport",&rb); if(rb.resval.rint == 1){ strcpy(blkName,ACDB_PAPER_SPACE); }else{ strcpy(blkName,ACDB_MODEL_SPACE); } }else{ strcpy(blkName,ACDB_MODEL_SPACE); } } AcDbBlockTable* pBlockTable; acdbHostApplicationServices()->workingDatabase() ->getSymbolTable(pBlockTable,AcDb::kForRead); AcDbBlockTableRecord *pBlockTableRecord; pBlockTable->getAt(blkName,pBlockTableRecord, AcDb::kForRead); AcDbBlockTableRecordIterator *pBlockIterator; pBlockTableRecord ->newIterator(pBlockIterator); for(;!pBlockIterator->done(); pBlockIterator->step()) { AcDbEntity *pEntity; pBlockIterator->getEntity(pEntity,AcDb::kForRead); AcDbHandle objHandle; pEntity->getAcDbHandle(objHandle); char handleStr[20]; objHandle.getIntoAsciiBuffer(handkeStr); const char *pCname = pEntity->isA()->name(); acutPrintf("对象ID%lx,名柄%s,类名%s.\n", pEntity->objId(),handleStr,pCname); pEntity->close(); } delete pBlockIterator; pBlockTableRecord->close(); acutPrintf("\n"); }
|
|