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

yang686526 2009-05-06 03:43 PM

【转帖】import dwf
 
import dwf
import dwf
i write that, and i have an error " .... was open for write objet : (6001)"
can you help me
thank you
thierry
///////////////////////////////////////////////////////////////////
oddbdatabaseptr pdb;
pdb = theapp.createdatabase(true, oddb::kmetric);
oddwfimportptr importer;
importer = createimporter();
if ( importer.isnull() ) return;
importer->properties()->putat( "database", pdb );
importer->properties()->putat( "dwfpath", odrxvariantvalue( odstring(l_fichierdwf) ) );
importer->properties()->putat( "password", odrxvariantvalue( odstring("") ) );
importer->properties()->putat( "paperwidth", odrxvariantvalue( 297. ) );
importer->properties()->putat( "paperheight", odrxvariantvalue( 210. ) );
importer->import();
try
{
odstreambufptr l_pfile = theapp.createfile(l_fichierdwg, oda::kfilewrite,
oda::ksharedenyreadwrite,
oda::kcreatealways);
pdb->writefile(l_pfile, oddb::kdwg, oddb::kdhl_1800,false);
}
catch(oderror& e)
{
cstring l_mess;
l_mess.format ("error saving document... %s",e.description());
afxmessagebox(l_mess);
}
///////////////////////////////////////////////////////////////////
it would be very helpful if you attached some complete sample showing the error (maybe some standard sample with changes)
try to put the importing code into a {} block:
code:
{
oddwfimportptr importer;
importer = createimporter();
if ( importer.isnull() ) return;
importer->properties()->putat( "database", pdb );
importer->properties()->putat( "dwfpath", odrxvariantvalue( odstring(l_fichierdwf) ) );
importer->properties()->putat( "password", odrxvariantvalue( odstring("") ) );
importer->properties()->putat( "paperwidth", odrxvariantvalue( 297. ) );
importer->properties()->putat( "paperheight", odrxvariantvalue( 210. ) );
importer->import();
}
it seems that importer holds smart pointer to some database object inside it. leaving the scope of oddwfimportptr the importer object gets destroyed.
this should be fixed inside dwf import but i hope that suggested work around works.
sergey slezkin
dwf import
thank you,
i have modified my code and it's work fine
best regards
thierry
///////////////////////////////////////////////////////////////////
oddbdatabaseptr pdb;
pdb = theapp.createdatabase(true, oddb::kmetric);
oddwfimportptr importer;
importer = createimporter();
if ( importer.isnull() ) return;
importer->properties()->putat( "database", pdb );
importer->properties()->putat( "dwfpath", odrxvariantvalue( odstring(l_fichierdwf) ) );
importer->properties()->putat( "password", odrxvariantvalue( odstring("") ) );
importer->properties()->putat( "paperwidth", odrxvariantvalue( 297. ) );
importer->properties()->putat( "paperheight", odrxvariantvalue( 210. ) );
importer->import();
importer.release;
try
{
odstreambufptr l_pfile = theapp.createfile(l_fichierdwg, oda::kfilewrite,
oda::ksharedenyreadwrite,
oda::kcreatealways);
pdb->writefile(l_pfile, oddb::kdwg, oddb::kdhl_1800,false);
}
catch(oderror& e)
{
cstring l_mess;
l_mess.format ("error saving document... %s",e.description());
afxmessagebox(l_mess);
}
///////////////////////////////////////////////////////////////////


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