几何尺寸与公差论坛------致力于产品几何量公差标准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-04, 03:42 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】add xdata to some entity cant be save in dwg forma

add xdata to some entity can't be save in dwg format
add xdata to some entity can't be save in dwg format
hi
i add some xdata to some kind of entity,like circle,line...
everything is ok,but when i save to dwg,it crash.the err msg is
"unhandled exception at 0x7c81eb33 in dwgviewer.exe: microsoft c++ exception: oderror @ 0x0012f258."
if i save as dxf,it,s ok.
can some one tell me why ?
regards,
heaven.jen
if the c++ exception is of oderror kind you can get error code and error description from it which may point out the reason.
probably you add an xdata providing application name which is absent in regapp table.
(you can use oddbdatabase::newregapp(const odstring& appname); to append the application to the database's regapp table.)
sergey slezkin
i have used newregapp in my app
i have used newregapp in my app.
if i haven,t use newregapp,it would crash in setxdata.
when i use setxdata,everything is ok until i save the file to "dwg".
i can't catch oderror,it crash immediately.
the code is show below
oddbentityptr pentity;
//get pentity use oddb::kforwrite
.....
byte *p;
long length;
//get some binary data i want to save to dwg
.....
odresbufptr xiter = odresbuf::newrb(odresbuf::kdxfregappname);
odresbufptr temp = xiter;
temp->setstring("xx");
temp->setnext( odresbuf::newrb(odresbuf::kdxfxdbinarychunk));
temp = temp->next();
odbitbinarydata data;
int i;
for(i=0;i<length;i++)
{
data.push_back(p[i]);
}
temp->setbinarychunk(data);
pentity->setxdata( xiter );
.....
cfilestreambuf filestreambuf; //inherit from odstreambuf
filestreambuf.attach(&file,false,false);
try
{
pdatabase->writefile(&filestreambuf,oddb::kdwg,oddb::vac15,f alse);//crash
}
catch(oderror *p)
{
//never into here
delete p;
}
if i use
pdatabase->writefile(&filestreambuf,oddb::kdxf,oddb::vac15,f alse)
.
it,s ok
last edited by yashu; 31st october 2004 at 05:23 pmfff">.
could you send me or post a dxf file with your xdata?
btw, probably you can't catch the oderror because catch should look like:
catch(oderror & err)
{
}
sergey slezkin
quote:
originally posted by sergey slezkin
could you send me or post a dxf file with your xdata?
btw, probably you can't catch the oderror because catch should look like:
catch(oderror & err)
{
}
i catch the err.
description is "object: (f9)"
code is 52
is it possible that by the moment you call writefile() a smart pointer still exists pointing to the circle?
if so it's the reason.
smart pointer holds the object in "opened" state. to release the object assign null to smart pointer or call
pcircle.release()
or smart pointer's destructor will release the object if the pointer goes out of scope.
sergey slezkin
quote:
originally posted by sergey slezkin
is it possible that by the moment you call writefile() a smart pointer still exists pointing to the circle?
if so it's the reason.
smart pointer holds the object in "opened" state. to release the object assign null to smart pointer or call
pcircle.release()
or smart pointer's destructor will release the object if the pointer goes out of scope.
no,
the oddbentityptr in my app is a local variant,when save to dwg,it have gone out of scope.
by the way,why dxf is ok ?
quote:
originally posted by yashu
no,
the oddbentityptr in my app is a local variant,when save to dwg,it have gone out of scope.
by the way,why dxf is ok ?
the bug have be found.it is my problem.
i create some cache to speed something.
you are right.i have something not be release before save.
thank's a lot. thank's
can you tell me why save to dxf is not crash ?
when object is closed it may perform some clean up, recalculations, send notifications to reactors which should perform some actions too etc.
in general it's not safe to save file with modified and not closed objects (invalid file may be produced).
the check is inserted in saving dwg but not inserted in saving dxf - our fault.
sergey slezkin

quote:
originally posted by sergey slezkin
when object is closed it may perform some clean up, recalculations, send notifications to reactors which should perform some actions too etc.
in general it's not safe to save file with modified and not closed objects (invalid file may be produced).
the check is inserted in saving dwg but not inserted in saving dxf - our fault.
thank you very much
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】实体的扩展数据xdata怎么删除啊?(已解决) - 精华帖集合 yang686526 ObjectARX(VB.NET/C#) 0 2009-04-29 05:30 PM
nons哥,save这种保存方法到底受那个变量控制它的保存版本 yang686526 ObjectARX(AutoLISP) 0 2009-04-25 08:43 PM
【转帖】使用.net从外部dwg文件中导入块 yang686526 ObjectARX(VB.NET/C#) 0 2009-04-20 06:18 PM
【转帖】[求助]请求编程,查询符合要求条件的dwg文件 yang686526 数据库ObjectDBX 0 2009-04-19 05:36 PM
【转帖】objectarx&dummies教程(十三)—— deriving from acdbentity yang686526 ObjectARX(C++) 0 2009-04-16 10:40 AM


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


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