几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【转帖】save File Changes (http://www.dimcax.com/hust/showthread.php?t=18495)

yang686526 2009-05-07 03:23 PM

【转帖】save File Changes
 
save file changes
save file changes
i tried to change dwg file and save it as follows. it threw an error "can not open file" while calling createfile in "write" mode (line 2). i thought that it was because the same file was already opened in line 1. then i changed line 2 to create a new file c:\test.dwg. it worked. i saved file changes to a new file. so my question is how to save file changes to itself?
thanks for any help.
oddbdatabaseptr pdb;
pdb = m_svcs.readfile( strftoprocess, false, false, oda::ksharedenyno ); // line 1
try
{
// change file here
}
catch(...)
{
//error handling code here
return;
}
odstreambufptr pfile;
oddb::savetype type = pdb->originalfiletype();
oddb:: dwgversion version = pdb->originalfileversion();
try
{
pfile = m_svcs.createfile(strftoprocess, oda::kfilewrite, oda::ksharedenywrite, oda::kopenexisting); // line 2
pdb->writefile(pfile, type, version, true);
}
catch(oderror& e)
{
// error handler
return;
}
last edited by xidongzhang; 9th february 2004 at 07:34 amfff">.
just use the
oddbdatabase::writefile()
method to write back. you don't need to re-create the same file.
thanks, walt.
but the first parameter of oddbdatabase::writefile() is odstreambuf* pfilebuff. how can we get the file buffer? (that's why i created the same file again.)


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