查看单个帖子
旧 2009-05-06, 04:40 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】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
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)