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

yang686526 2009-05-04 03:43 PM

【转帖】adding a table record
 
adding a table record
adding a table record
hi all,
i'm having trouble adding a new table record; although odamfeapp has no problem reading the generated file, autocad says the file is an "unrecognised file format". if i don't add the table record the saved file is read by autocad just fine; so i think this is the code that is problematic. is there something i'm missing?
oddbblocktableptr ptable = pdb->getblocktableid().safeopenobject(oddb::kforwri te);
oddbblocktablerecordptr pblock3 = oddbblocktablerecord::createobject();
// block must have a name before adding it to the table.
pblock3->setname("border");
// add the object to the table.
oddbobjectid id = ptable->add(pblock3);
this code executes just fine and in the odamfcapp it reads fine, but autocad baulks. can anyone point out my problem?

never mind. i see that the newly created block table must me closed before anything can be added to it. i accomplished it by limiting the scope of the table and record pointers. what would be another way to specifically close an object other than letting the smart pointers go out of scope?

if a smart pointer points to an object the object is not closed. while closing object if it was modified some actions are performed to check its validity, send notifications to reactors etc.
for example then newly created block table record is closed block begin and block end entities are created if they were missing.
currently dd client code has opportunity to write database to file without closing objects. as a result block table record can be saved to file without block begin and block end. probably it would be better to throw exception if an attempt is made to save opened for write object to file.
>what would be another way to specifically close
>an object other than letting the smart pointers
>go out of scope?
other method is to call pointer's release() method or set it to null by assignment operator.
sergey slezkin


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