高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】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);
}
///////////////////////////////////////////////////////////////////
|