几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【转帖】block iteration order (http://www.dimcax.com/hust/showthread.php?t=15235)

yang686526 2009-05-04 04:47 PM

【转帖】block iteration order
 
block iteration order
block iteration order
for export dwg to my application i use follow code:
[code] oddbblocktableptr pacblocks = m_db->getblocktableid().safeopenobject();
oddbsymboltableiteratorptr piter = pacblocks->newiterator();
for(piter->start(); !piter->done(); piter->step())
{
oddbblocktablerecordptr pacblock = piter->getrecordid().safeopenobject();
// create block in my application term
} </pre><hr></blockquote>
but first in iterator is model space, which contain reference to other block. these blocks don抰 iterate yet and so didn抰 create.
is any way to iterate blocks in they inclusion order. it means: first i get blocks that contain only simple geometry entities, then blocks that contain geometry and already read blocks and ?layout block should be latest.
best regards,
ivan obraztsov

you could use islayout property to check for layout block:
if (pacblock-&gt;islayout())
{
//save this block id for further processing
continue;
}
there are no special functions to detect is this block contains reference to other blocks.
so you have to iterate through the block entities and check is it block ref. but you'll have to handle the situation when the blockref contains another one blockref and so on. may be it could be easy to create the empty block and populate it later when you will process this block ?

the problem is: our application doesn抰 allow create empty blocks.
best regards,
ivan obraztsov

can you create a dummy blocks containing anything and repopulate them having come across their definition?
else you need to iterate through blocks at least twice: first to build reference graph and second to process the blocks. more programming and slower performance.
sergey slezkin


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