|
- // 炸开
- void BomEntity()
- {
- AcDbBlockTable *pBlkTbl;
- acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl, AcDb::kForRead);
- // 获得模型空间的块表记录
- AcDbBlockTableRecord *pBlkTblRcd;
- pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd,AcDb::kForRead);
- pBlkTbl->close();
- // 创建块表记录遍历器
- AcDbBlockTableRecordIterator *pItr; // 块表记录遍历器
- pBlkTblRcd -> newIterator(pItr);
- pBlkTblRcd->close();
- AcDbEntity *pEnt = NULL; // 遍历的临时实体指针
- for(pItr->start();!pItr->done();pItr->step()){
- // 利用遍历器获得每一个实体
- pItr->getEntity(pEnt,AcDb::kForWrite);
- // 块参照
- if (pEnt->isKindOf(AcDbBlockReference::desc()))
- {
- // 炸开
- AcDbVoidPtrArray ents =Explode(pEnt);
- // 循环遍历炸开的实体
- for(int i = 0; i < ents.length(); ++i)
- {
- AcDbEntity* pSubEnt = (AcDbEntity*)ents[i];
- AcDbEntity* entity = AcDbEntity::cast(pSubEnt);
- AppendToDatabase(entity);
- entity->close();
- }
- pEnt->erase();
- }
- pEnt->close();
- }
- delete pItr;
- }
复制代码 |
|