|
高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】raverse The Entities In The Block Table 9probl
traverse the entities in the block table (problem?)
traverse the entities in the block table (problem?)
hello,
i have a followed problem:
while i traverse through the block's entity list, i want to add or/and delete some entities from database. but if i do that, exception happens.
here is simple example:
oddbobjectiteratorptr pentiter = pblock->newiterator();
for (; !pentiter->done(); pentiter->step())
{
oddbentityptr pent = pentiter->objectid().safeopenobject(oddb::kforwrite);
if (pent->iskindof(oddbline::desc()))
pent->erase();
}
if i run this example on a drawing with lines, exception occurs when iterator moves to next element, right after first entity is deleted.
exception which i get is:
object was permanently erased
is this maybe a problem of dwgdirect library, or is iterator and the block entity list implemented in a way, that this is not possible?
is there any way, to add or delete elements from current block, while traversing through it?
regards, tomaz
the world is still far from ideal...
current dd implementation has a "feature":
if your application does not use undo filer objects get erased permanently and if iterator's current object is erased step() crashes. to avoid it you can call step() before erasing the object.
sergey slezkin
|