几何尺寸与公差论坛------致力于产品几何量公差标准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, 05:20 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】losing objects when writing dwg file

losing objects when writing dwg file
losing objects when writing dwg file
using dwgdirect 2.5.2, windows xp, visual studio 2005.
i am writing a program that performs coordinate system transformations on the coordinates in dwg files. the basic logic for transforming the objects in the file is:
code:
// load the file
// blkiter is a block table iterator
// open the block and iterate through its contained entities
oddbblocktablerecordptr pblock = blkiter->getrecordid().safeopenobject();
oddbobjectiteratorptr pentiter;
for (pentiter = pblock->newiterator(); !pentiter->done(); pentiter->step())
{
oddbentityptr pentity = pentiter->entity(oddb::kforwrite);
// retrieve the protocol extension and transform the entity
odsmartptr<bautocadloader> pentloader = pentity;
pentloader->transform(pentity, pacadtransform);
}
// write the file.in most cases, this works fine, but i have run into a file where i get a very strange result (the file is attached). when i write the output file, the model space block only contains the first object from the input file. the new coordinates in the object are correct, but there is only one object.
the attached file appears to be an autocad 2000 file. if i load it into autocad 2004 and save it as an autocad 2004 file, then the transformation works fine (i.e., the output contains all objects). if i save it as an autocad 2000 file, then the transformation fails (output contains 1 object).
i have tried having my program write the file as both autocad 2004 and autocad 2000, and the resulting file still has only 1 model space object.
this file can be loaded and displayed in the odamfcapp program, and we can load it into our own viewer program. there appears to be a problem with modifying the file contents in place, then writing the file out.
does anyone have any insight into this issue?
thanks.
bob
can it be reproduced by just calling transformby() with some matrix, w/o your protocol extension?
vladimir
i'm using coordinate conversion libraries that convert points based on coordinate system definitions. i don't have a good way to get a matrix that represents that transformation.
also, i tried re-ran my test using dwgdirect 2.6.1, and the problem is still there.
i ran the following test on your file:
code:
oddbblocktableptr bt = pdbcmdctx->database()->getblocktableid().safeopenobject();
for (oddbsymboltableiteratorptr i1 = bt->newiterator(); !i1->done(); i1->step())
{
oddbblocktablerecordptr pblock = i1->getrecordid().safeopenobject();
oddbobjectiteratorptr pentiter;
for (pentiter = pblock->newiterator(); !pentiter->done(); pentiter->step())
{
oddbentityptr pentity = pentiter->entity(oddb::kforwrite);
pentity->transformby(odgematrix3d::translation(odgevector3d(1.0, 0.0, 0.0)));
}
}after the test, all the entities are present in saved drawing. there is something in your transformation code.
try to close entity smart pointer and reopen it, to make sure it was not e.g. erased during transformation.
vladimir
the file contains many oddbpoint objects. the protocol extension for oddbpoints looks like this:
code:
void transform(oddbentity* pentity, const bautocadcoordtransformptr& pct) const
{
oddbpointptr pdwgpoint = pentity;
// perform the coordinate transformation
pdwgpoint->setposition(pct->transformacadpoint(pdwgpoint->position()));
}and the transformacadpoint method looks like this:
code:
odgepoint3d transformacadpoint(const odgepoint3d& acadpt)
{
bpoint ptin(acadpt.x, acadpt.y, acadpt.z);
bpoint ptout = convertsourcetotarget(ptin);
return odgepoint3d(ptout.x, ptout.y, ptout.z);
}it is pretty simple, and i don't think the entity pointer is being erased. there are no exceptions being thrown. the strange thing is that my code works every file i've tried it with except for the one that i attached, which leads me to believe that there is something odd about that file. i've tried auditing it in autocad, but no errors were reported, and if i save the file from autocad in autocad 2004 format, it gets handled properly.
one other thing i forgot to mention is that i am using a page controller. after each group of 200 objects, i make a call to oddbpageobjects(). i have traced through those calls, and they seem to be ok. the write() calls seem to be returning 'true'. my page controller implementation is very similar to the sample provided in the toolkit.
actually, in current version, paging is not very useful, because, while saving, all the objects willl be loaded back, and if paging is called while saving - invalid file may be produced. (there was a bug found recently, that breaks paging while saving)
try to turn off paging - will your test be working correctly then?
vladimir
i turned off paging and that seemed to fix the problem.
when do you expect the paging bug to be fixed?
the bug (5237) is fixed. the fix is available for fonding members from svn. binary maintenance release is planned for autumn.
the bug effects saving r13,14,15 dwg files.
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
旧 2011-11-24, 02:10 AM   #2
JDempsey
初级会员
 
注册日期: 11-11
帖子: 2
精华: 0
现金: 24 标准币
资产: 24 标准币
JDempsey 向着好的方向发展
默认 回复: 【转帖】losing objects when writing dwg file

Repairing .dwg files it's for dwg recover. The program works under any Windows OS. The utility restores .dwg files after hdd failures, malicious software. The utility uses high end ways of restoring autocad data.
JDempsey离线中   回复时引用此帖
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】geometry related questions yang686526 DirectDWG 0 2009-05-05 11:12 AM
【转帖】exportdwf cant deal with ole objects in a dwg file yang686526 DirectDWG 0 2009-05-05 10:29 AM
【转帖】custom objects yang686526 DirectDWG 0 2009-05-04 06:56 PM
【转帖】crash while loading dwg yang686526 DirectDWG 0 2009-05-04 06:38 PM
【转帖】cant see objects in some file yang686526 DirectDWG 0 2009-05-04 05:36 PM


所有的时间均为北京时间。 现在的时间是 12:10 AM.


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