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

yang686526 2009-05-07 03:40 PM

【转帖】setinsunits Throws Exception
 
setinsunits throws exception
setinsunits throws exception
m_rdxffile->setinsunits(oddb::kunitsmillimeters);
this code throws an exception.
i've created a new drawing and i need to set the insunits. like it is done with the insunits command in autocad.
how can i do that?
-rune jorgensen
be sure the m_rdxffile is a valid pointer to oddbdatabase object.
is it oddbdatabaseptr or oddbdatabase *?
the code below will crash:
code:
oddbdatabase * pdb = pservices->createdatabase();
pdb->anyfunction(); // crash because database is destroyed
createdatabase() returns smart pointer. number of references to database is 1. smart pointer destructor destroys database.
sergey slezkin
oddbdatabaseptr
m_rdxffile;
it isn't a "read-only variable" issue?
-rune jorgensen

this is not a read-only variable.
is the pointer to database valid by the moment you call setinsunits()? can you call any other set<variable>() function at this moment?
what kind of exception do you get?
is it possible to reproduce the situation in one of our samples (for example by inserting a piece of code in odwriteex)?
sergey slezkin
sergey, you were right as usual. it turned out that setinsunits() could under certain condition be called before createdatabase(). that fixed, everything works as expected.
thanks!
-rune
-rune jorgensen


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