几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【转帖】changing the font associated with the standard text style (http://www.dimcax.com/hust/showthread.php?t=15398)

yang686526 2009-05-04 05:44 PM

【转帖】changing the font associated with the standard text style
 
changing the font associated with the "standard" text style.
changing the font associated with the "standard" text style.
hello, i've been using the following code in order to establish "romans.shx" as the font associated with the standard text style (i have deleted the unnecessary code):
code:
cstring strfilenamedwg;
strfilenamedwg = "c:\\test.dwg";
odwrfilebuf fb(strfilenamedwg);
oddbdatabaseptr pdb = this->createdatabase(true,oddb::kmetric);
oddbobjectid idstdtextstyle = pdb->gettextstylestandardid();
oddbtextstyletablerecordptr ptextstyletablerecordptr =
idstdtextstyle.safeopenobject(oddb::kforwrite);
strtextfilename = "romans.shx";
cstring strpath = "c:\\prog sbesa";
if(!finder.findfile(strpath + "\\" + strtextfilename))
{
cstring strmessage;
strmessage = "didn't find the file";
afxmessagebox(strmessage);
}
ptextstyletablerecordptr->setfilename((odstring&)(strpath + "\\" + strtextfilename));
oddb::savetype filetype;
oddb::dwgversion outver;
filetype = oddb::kdwg;
outver = oddb::vac14;

pdb->writefile(&fb, filetype, outver);
auditinfo aiappaudit;
aiappaudit.setfixerrors(true);
aiappaudit.setprintdest(oddbauditinfo::kboth);
//aiappaudit.sethostappservices(&theapp);
pdb->auditdatabase(&aiappaudit);
std(cout) << "database has been saved to: " << pdb->getfilename().c_str() << std(endl);
}
catch(oderror& e)
{
std(cout) << "error :" << this->geterrordescription(e.code()).c_str() << std(endl);
}
catch(...)
{
std(cout) << "unexpected error." << std(endl);
}
with dd109 this has been working fine but with dd111.01 the program launches an exception while executing "pdb->writefile(&fb, filetype, outver);" with message "was open for write".
audit doesn't report errors.
any idea?
thanks in advance.
the reason is that text style table record you modified is still opened for write while writing the file.
it must be closed. this can be done by calling
ptextstyletablerecordptr.release();
or
ptextstyletablerecordptr = 0;
or
if your smart pointer goes out of scope by the moment the writefile() is called (its destructor will close the object it's referencing if the reference is the last one).
sergey slezkin


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