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

yang686526 2009-05-06 04:40 PM

【转帖】layout block records order
 
layout block records order
layout block records order
hi,
i need to know the order of the block layouts in the way they appear in the autocad tabs at the bottom of the drawing window.
i use this code to take the names:
code:
void getlayoutnames(vector<string>& names)
{
try {
// iterate all the blocks and return the model and paperspaces;
oddbblocktableptr pblocks = pdb->getblocktableid().safeopenobject();
oddbsymboltableiteratorptr piter = pblocks->newiterator();

for (piter->start(); !piter->done(); piter->step()) {
oddbblocktablerecordptr pblock = piter->getrecord();
if (pblock->islayout()) {
oddblayoutptr playout = pblock->getlayoutid().safeopenobject();
names.push_back((lpctstr)playout->getlayoutname());
} //if
} //for
} catch (oderror& e) {
reportoderror(e);
names.clear();
} //catch
}
the problem comes when an autocad database is stored with some active paperspace.
the first record is always the model space ("model"), but the second is always the active paperspace. then the remainder is ok.
where is the wrong thing here?
the layout dictionary stores the names in alphabetic order and is useless. is there any index to retreive?
thanks in advance for any help.
regards
chudomir
use oddblayout::gettaborder() method.
btw, the drawing may contain a huge number of blocks and it's much more efficient to use layout dictionary than iterating through all blocks.
sergey slezkin
i knew it was simple, thank you!
you're right for the blocks iteration, anyway, this function was not a bottleneck...
regards
chudomir


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