![]() |
【转帖】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! |
所有的时间均为北京时间。 现在的时间是 06:13 PM. |