查看单个帖子
旧 2009-05-06, 04:39 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】layers

layers
layers
i'm having trouble converting my code from opendwg to dwgdirect. there are plenty of examples in the code of iterating through the layers, but i cannot get a simple bit of code like this:
oddblayertableptr players;
players = m_pdb->getlayertableid().safeopenobject(oddb::kforwrite) ;
bool b1 = players->has((const char*)strtemp);
to successfully tell me that there is a layer that i just created. when i save the file, the layer is there, but i cannot get code that will find it or access it.
any idea what is up, or better examples of code to do such things?
some code example
oddbblocktableptr pblocks = pdb->getblocktableid() . safeopenobject();
oddbsymboltableiteratorptr pblkiter = pblocks->newiterator();
for ( pblkiter->start(); ! pblkiter->done(); pblkiter->step() )
{
oddbblocktablerecordptr pblock = pblkiter->getrecordid().safeopenobject();
if ( !stricmp (name,pblock->getname()) )
{
recordid = pblkiter->getrecordid();
break;
}
}
....
with the recordid you have access to the object
i checked the code below. it works.
code:
oddblayertableptr pt = pdb->getlayertableid().safeopenobject(oddb::kforwrite);
bool bexists = pt->has("mylayer");
if (!bexists)
{
oddblayertablerecordptr pl = oddblayertablerecord::createobject();
pl->setname("mylayer");
pt->add(pl);
bexists = pt->has("mylayer");
// here bexists is true
}
sergey slezkin
thank you very much. i had just figured out that the "has" and 'getat" should do it for me, but they were refusing to work. i pasted in your code, which then worked fine. turned out i had a bug in my test harness.
appreciate the advice!
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)