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

dxf looks different from dwg
dxf looks different from dwg
i create a cad image and save it as dwg and dxf. why i got the differences (i've attached the files).
i check objects and find the spline that is defferent. in spline's control points there are:
dwg point (x y z)
1. (8540,00 1000 0)
2. (8473,29 1000 0)
3. (8560,44 1000 0)
4. (8743,01 1000 0)
5. (9020,25 1000 0)
6. (9365,10 1000 0)
7. (9750,53 1000 0)
8. (10149,47 1000 0)
9. (10534,90 1000 0)
10. (10879,75 1000 0)
11. (11156,99 1000 0)
12. (11339,56 1000 0)
13. (11426,71 1000 0)
14. (11450,00 1000 0)
dxf point (x y z)
1. (8540,00 1000 0)
2. (8473,29 1000 0)
3. (8560,44 1000 0)
4. (8743,01 1000 0)
5. (9020,25 1000 0)
6. (9365,10 1000 0)
7. (9750,53 1000 0)
8. (10149,47 0 0)
9. (10534,90 1000 0)
10. (10879,75 1000 0)
11. (11156,99 1000 0)
12. (11339,56 1000 0)
13. (11426,71 1000 0)
14. (11450,00 1000 0)
why after writing dxf the spline control point y-pos was set to 0 (point 8)?
i'm not sure but that effects in autocad crash during opening dxf file.
attached files
hi
look at line 22290 in dxf. i dont know why it here (0:00.0). i cannot reproduce it in our current tookit version. what is your toolkit version ?
version
hi,
my version is 1.14.02. i generate both files in the same way, because decision of beeing dxf or dwg is just before
code:
m_pdb->writefile(&vfilebuff, vtype, vversion, false, adxfprecision);
maybe adxfprecision which is 16 is the problem?
is it reproducible in mfcapp ? is it in debug or release mode ? (or only in release, but debug is ok ?) did you use toolkit for vc6/vc7/vc8?
unfortunatelly i cannot reproduce it in mfcapp (after open dwg and save dxf - there was ok).
i'm using visual studio 2003, the libs: dd_vc2003md_ ...
and i got that effect only in release mode in debug everything is ok.
what is the dxf file creation way ?
dxf creation
it is rather compliated because this is a kind of export.
1) creating empty database:
shortly:
code:
...
oddb::measurementvalue measure = (oddb::measurementvalue)ameasure;
oddbdatabaseptr pdb = createdatabase(true, measure);
pdb->settilemode(1);
pdb->setlwdisplay(true);
oddbdate date;
date.getlocaltime();
oddbsettducreate(*pdb, date);
oddbviewporttableptr pvptable = pdb->getviewporttableid().openobject(oddb::kforwrite);
oddbobjectid vpid = pvptable->getactiveviewportid();
oddbviewporttablerecordptr vportrec = vpid.openobject(oddb::kforwrite);
vportrec->setcenterpoint(odgepoint2d(11.26, 4.5));
vportrec->setwidth(22.53);
vportrec->setheight(9.);
...
setviewportborderproperties(m_pdevice, true);

oddbblocktablerecordptr pblcltblrec = pdb->getactivelayoutbtrid().safeopenobject();
oddblayoutptr playout = pblcltblrec->getlayoutid().safeopenobject();
oddbobjectid actid = playout->lastactivevportid();
if (actid)
{
oddbviewportptr pvp = actid.safeopenobject(oddb::kforwrite);
pvp->setfastzoomon();
}
if (azoomextents)
viewzoomextents(aviewid);
...
code:
void mfcdwgximpl::setviewportborderproperties(odgsdevice* pdevice, bool bmodel)
{
// if current layout is model and it hase more then one viewport then
// let's make their borders visible.
// if current layout is paper then let's make visible borders of all viewports
// exept overall one's.
int n = pdevice->numviews();
if(n>1)
{
for(int i = bmodel ? 0 : 1; i<n; ++i)
{
odgsviewptr pview = pdevice->viewat(i);
pview->setmode(odgsview::k2doptimized);
pview->setviewportbordervisibility(true);
pview->setviewportborderproperties(curpalette()[7], 1);
}
}
}
2) creating default linetypes, patterns, and so on
3) selecting layer or creating if doesn't exists.
4) creating objects (f.e. splines) on selected layers
code:
hresult stdmethodcalltype dwgdrawximpl:lotspline(idwgcollection *afitpoints, idwgpoint *astarttangent, idwgpoint *aendtangent, int adegree, idwgspline **adwgspline)
{
oddbblocktablerecordptr pms = m_pdb->getmodelspaceid().safeopenobject(oddb::kforwrite);
oddbsplineptr poddbspline = oddbspline::createobject();
poddbspline->setdatabasedefaults(m_pdb);
poddbspline->setlayer(m_player->getname());
odgepoint3darray vfitpoints;
int vcount;
afitpoints->getcount(&vcount);
for (int i = 0; i<vcount; i++)
{
// ustal punkt
idwgobject *pdwgobject = null;
afitpoints->getitem(i, &pdwgobject);
idwgpoint *pdwgpoint = null;
if (pdwgobject->queryinterface(iid_idwgpoint, (void **)&pdwgpoint) == s_ok)
{
double x, y, z;
pdwgpoint->getpos(&x, &y, &z);
odgepoint3d vfitpoint(x, y, z);
vfitpoints.push_back(vfitpoint);
//poddbspline->insertfitpointat(i, vfitpoint);
pdwgpoint->release();
}
//pdwgobject->release();
}
double x1, y1, z1, x2, y2, z2;
astarttangent->getpos(&x1, &y1, &z1);
aendtangent->getpos(&x2, &y2, &z2);
odgevector3d vstarttangent(x1, y1, z1), vendtangent(x2, y2, z2);
//vstarttangent = vstarttangent.normalize(1.0e-10);
//vendtangent = vendtangent.normalize(1.0e-10);
double vfittolerance = 10e-3;
poddbspline->setfitdata(vfitpoints, adegree, vfittolerance, vstarttangent, vendtangent);
poddbspline->purgefitdata();
pms->appendoddbentity(poddbspline);
if (!m_pview.isnull())
m_pview->add(poddbspline, 0);
hresult hr = createdwgobject(poddbspline, (idwgobject **)adwgspline, m_pwarninglistener);
poddbspline = null;
pms = null;
return hr;
}
5) saving
code:
hresult stdmethodcalltype dwgdrawximpl::savetofile(wchar_t *afilename, int asavetype, int adwgversion, int adxfprecision)
{
closelayer();
m_pdb->closeinput();
if (m_pdb->iswriteenabled())
m_pdb->downgradeopen();
odrxobjectimpl<odwrfilebuf> vfilebuff;
vfilebuff.open(afilename);
oddb::savetype vtype = (oddb::savetype)asavetype;
oddb::dwgversion vversion = (oddb::dwgversion)adwgversion;
//vversion = oddb::vac18;
oddbauditinfo ainfo;
ainfo.setfixerrors(true);
m_pdb->auditdatabase(&ainfo);
oddbdate date;
date.getlocaltime();
oddbsettduupdate(*m_pdb, date);
if (m_pdb->gettilemode()) //model space
{
oddbviewporttableptr pvptbl = m_pdb->getviewporttableid().safeopenobject();
oddbobjectid id = pvptbl->getactiveviewportid();
if (id)
{
oddbviewporttablerecordptr prec = id.safeopenobject(oddb::kforwrite);
//prec->zoomextents(); <-- bug #1253
if (prec->height() ==0)
prec->setheight(1.0);
prec = null;
id = null;
}
pvptbl = null;
// create a new layout
oddbobjectid newlayoutid = m_pdb->createlayout("ddt layout");
oddblayoutptr playout = newlayoutid.safeopenobject();
m_pdb->setcurrentlayout(newlayoutid); // also creates overall (paperspase) viewport
oddbviewportptr poverallvp = playout->overallvportid().safeopenobject();
odgepoint3d overallcenter = poverallvp->centerpoint();
// create viewport with all modelspace entities
//
oddbviewportptr pnewvp = oddbviewport::createobject();
oddbblocktablerecordptr pnewps = playout->getblocktablerecordid().safeopenobject(oddb::kforwrite);
pnewps->appendoddbentity(pnewvp);
pnewvp->setwidth(poverallvp->width());
pnewvp->setheight(poverallvp->height()*0.5);
pnewvp->setcenterpoint(odgepoint3d(overallcenter.x, overallcenter.y*1.5, 0.));
//messagebox(0, "setviewcenter...", "info", 0);
pnewvp->setviewcenter(poverallvp->viewcenter());
// pnewvp->zoomextents(); // <- mem leaks
pnewps = null;
pnewvp = null;
poverallvp = null;
playout = null;
newlayoutid = null;
}
else
{
oddbblocktablerecordptr pblcltblrec = m_pdb->getactivelayoutbtrid().safeopenobject();
oddblayoutptr playout = pblcltblrec->getlayoutid().safeopenobject();
oddbobjectid actid = playout->lastactivevportid();
if (actid)
{
oddbviewportptr pvp = actid.safeopenobject(oddb::kforwrite);
pvp->zoomextents();
pvp = null;
actid = null;
}
playout = null;
pblcltblrec = null;
}
// if preview bitmap is already available it can be specified to avoid wasting
// time on generating it by dd
const odchar* pbmpfilename = "preview.bmp";
if(:dsystemservices()->accessfile(pbmpfilename, oda::kfileread))
{
odrdfilebuf bmpfile(pbmpfilename);
odarray<oduint8> buf;
buf.resize(bmpfile.length());
oduint8 * pdata = buf.asarrayptr();
bmpfile.getbytes(pdata, buf.length());
// get length taking care about big-endian
oduint32 length = pdata[2] + (pdata[3] << 8);
pdata += 14; // skip bitmapfileheader
m_pdb->setthumbnailbitmap(pdata, length);
}
m_pdb->writefile(&vfilebuff, vtype, vversion, false, adxfprecision);
vfilebuff.close();
return s_ok;
}
i cannot reproduce it i need small sample which help to reproduce problem. for example - create default database, create one spline with points defined in code, save it to dxf -> bug.
does toolkit save wrong dxf each time you made export from original file?
bug in release is possibly result of optimization. try to compile your application without optimization by speed or by size. if you have toolkit sources, try to compile it without optimization. if you havn't toolkit sources, try to change toolkit release dlls by debug dlls. it is not good operation but it help us to find bad module. (dd_db.dll, dd_ge.dll)
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】dwg file coordinates to world yang686526 DirectDWG 0 2009-05-05 08:02 AM
【转帖】dwg extension in world coordinates yang686526 DirectDWG 0 2009-05-05 08:01 AM
【转帖】converting attached dwg to dwf fails yang686526 DirectDWG 0 2009-05-04 06:14 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


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


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