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

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】dxf looks different from dwg (http://www.dimcax.com/hust/showthread.php?t=16013)

yang686526 2009-05-05 08:51 AM

【转帖】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::plotspline(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(::odsystemservices()->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)


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