![]() |
【转帖】problem using oddbdatabaseinsert function
problem using oddbdatabase::insert function
problem using oddbdatabase::insert function hi, what i'm trying to do is inserting a blockrecord from one database to another database. i'm doing this by using this function: code: oddbobjectid oddbdatabase::insert( const odstring& sourceblockname, const odstring& destinationblockname, oddbdatabase* psource, bool preservesourcedatabase = true); but the result is not what i expected. in the destination database two blockrecords are created. one is a blockrecord with the sourceblockname, the second has destinationblockname as name. the second record is also completly empty (--> no entities in there). the first one has all its entities, but not usable because of the name. i'm working with version 1.14.01. what can i do to work around this? i've already tried deepcloning but that also gives me an empty record. this is a bug of dd. it will be fixed in the next maintenance release. for the moment you can use oddbdatabase::wblockcloneobjects method as workaround: code: oddbblocktableptr pblocks = psrcdb->getblocktableid().safeopenobject(); oddbobjectid blockid = pblocks->getat("block1"); oddbidmappingptr pmap = oddbidmapping::createobject(); oddbobjectidarray objects; objects.push_back(blockid); psrcdb->wblockcloneobjects(objects, pdstdb->getblocktableid(), *pmap, oddb::kdrcreplace); oddbidpair blockspair(blockid); pmap->compute(blockspair); oddbblocktablerecordptr pnewblock = blockspair.value().safeopenobject(oddb::kforwrite); pnewblock->setname("insertedblock1"); regards, sergey vishnevetsky thanks for the workaround! problem: not view insert block when executing the previous code everything goes well, but when opening the drawing where i copy the block, i do not see the block and i have it to insert by hand with the commando of autocad 揑nsert?as i can solve this problem? the code above copies blocktablerecord but it does not create blockreference entity. sergey slezkin draw block once copied the block, how i can draw it? , that is to say, how i can create a 揃lockreference?and insert it in 搈odel_space? thanks look at oddbwriteex sample. it illustrates creating of most entities. search ib dbfiller.cpp for oddbblockreference::createobject() sergey slezkin thanks, already i have been able to bring a block of an external drawing. invalid owner hi, i also faced the same issue while inserting the block to a database. so tried with this work around that was earlier provided. but iam getting an empty dwg file. this is because it is raising invalid owner object exception in this line of code. (while calling wblockcloneobjects)please let me know a sol for this asap. psrcdb->wblockcloneobjects(objects, pdstdb->getblocktableid(), *pmap, oddb::kdrcreplace); thanks in adv aparna last edited by aparna; 13th august 2007 at 12:10 amfff">. how the problem can be reproduced? sergey slezkin problem hi sergey, i want to insert blocks existing in one database to a new database. so i used the below functionality of inserting blocks. oddbobjectid oddbdatabase::insert( const odstring& sourceblockname, const odstring& destinationblockname, oddbdatabase* psource, bool preservesourcedatabase = true); when i used a customer provided .dwg file (contains blocks)to insert the blocks to a new database iam getting noclassid error while executing the above method. so then i proceeded with the workaround that was provided in this thread. but even then iam unable to proceed further as iam getting invalid owner object when using wblockcloneobjects. please let me know a sol to this problem asap. thanks in adv aparna which dd version do you use? i checked it in odamfcapp 2.4.1: excustobjs project contains a number of test/debug commands among them test fro insert() function. below is modified code from drxdebugcmds.cpp. it works with simple test file with block. maybe the problem is caused by specific file? code: // // tests insert database // void _testdbinsert_func(odedcommandcontext* pcmdctx) { oddbcommandcontextptr pdbcmdctx(pcmdctx); oddbdatabaseptr pdb = pdbcmdctx->database(); oddbuserio* pio = oddbuserio::cast(pdbcmdctx->userio()); if (!pio) return; odstring fname = pio->getfilepath(dd_t("enter file name to insert:"), oded::kgfpforopen, dd_t("select drawing to insert"), dd_t("dwg"), odstring::kempty, dd_t("ddt drawing (*.dwg)|*.dwg||")); oddbdatabaseptr psrcdb = pdb->appservices()->readfile(fname); if (psrcdb.get()) { // pdb->insert(dd_t("insertedblock1"), psrcdb); // pdb->insert(dd_t("*model_space"), dd_t("insertedblock2"), psrcdb); pdb->insert(dd_t("testblock"), dd_t("insertedblock2"), psrcdb); // pdb->insert(odgescale3d(0.75, 1.25, 1.0), psrcdb); //pdb->insert(odgematrix3d::kidentity, psrcdb); } } sergey slezkin hi sergey, thanks a lot for the code. even with this part of code when i tried to insert the blocks from psrcdb to pdb iam getting noclassid error.can you tell me what this error indicates? is it that something might be missing in the customer provided .dwg file. thanks in adv aparna if the file you are inserting block from can be loaded ok and recover does not report errors it may be a bug in dwgdirect. are you using 2.4.1? i can look more close into this problem if i can reproduce the situation (sample file + block name you are inserting). sergey slezkin |
所有的时间均为北京时间。 现在的时间是 12:05 AM. |