几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】raverse The Entities In The Block Table 9probl (http://www.dimcax.com/hust/showthread.php?t=18812)

yang686526 2009-05-07 05:15 PM

【转帖】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


所有的时间均为北京时间。 现在的时间是 04:15 AM.