TA的每日心情![](source/plugin/dsu_paulsign/img/emot/kx.gif) | 开心 昨天 15:23 |
---|
签到天数: 69 天 [LV.6]常住居民II
管理员
- 积分
- 2704
|
查找删除的实体
问题:
如何强制AcDbBlockTableRecordIterator不跳过已擦除的实体?
解答:
为避免跳过已擦除的实体,必须为最后一个参数指定false
在AcDbBlockTableRecord类的newIterator()方法中
可选,并设置为true(即跳过已擦除的实体)。
下面的示例代码将列出在模型空间中删除的所有实体。
注释包含在需要指定正确参数的位置
遍历删除的实体。
void fTest()
{
AcDbBlockTable *pBT;
AcDbBlockTableRecord *pBTR;
AcDbBlockTableRecordIterator *pIter;
acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBT,AcDb::kForRead);
pBT->getAt(ACDB_MODEL_SPACE,pBTR,AcDb::kForWrite);
pBT->close();
//the last parameter should be false to get the erased entities
pBTR->newIterator(pIter,true,false);
pBTR->close();
int mCtr = 0;
AcDbEntity *pEnt;
Acad::ErrorStatus es;
while(!pIter->done())
{
//if you specify true for last parameter then you will not get eWasErased notification.
//but this also means you will not be able to open the erased object
es = pIter->getEntity(pEnt,AcDb::kForWrite,false);
if (es == Acad::eWasErased)
{
mCtr++;
acutPrintf("\neWasErased, Entity number : %d",mCtr);
}
else
{
pEnt->close();
}
//the last parameter should be false to get the erased entities
pIter->step(true,false);
}
acutPrintf("\nTotal number of erased entities: %i",mCtr);
delete pIter;
} |
|