几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


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


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】error c2664 yang686526 DirectDWG 0 2009-05-05 09:34 AM
【转帖】ambiguous call to overload functions in odstring.h yang686526 DirectDWG 0 2009-05-04 03:56 PM
【转帖】在vba里由基本三角函数导出的三角函数 yang686526 数据库ObjectDBX 0 2009-04-28 12:25 PM
【转帖】哪位高手指点一下下边lisp的怎么用 yang686526 数据库ObjectDBX 0 2009-04-28 12:13 PM
哪位高手指点一下下边lisp的怎么用 yang686526 ObjectARX(AutoLISP) 0 2009-04-26 06:19 PM


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


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多