ReadDwgFile - side database correct useage
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
All, I have struck some seemingly contradictory information and would appreciate a comment on the correct method to access a side database (dwg), edit, and save to the same name. I have been doing this for ages but now wonder if correctly:
// Fenton version
public static void DoSomeWorkExt01(string DwgToProcess)
{
using (Database db = new Database(false, true))
{
db.ReadDwgFile(DwgToProcess, FileOpenMode.OpenForReadAndReadShare, false, "");
// closing the input makes sure the whole dwg is read from disk
// it also closes the file so you can SaveAs the same name
db.CloseInput(true);
// store the current working database, to reset
Database currDb = HostApplicationServices.WorkingDatabase;
// set working database
HostApplicationServices.WorkingDatabase = db;
{Do Some Work}
db.SaveAs(DwgToProcess, DwgVersion.Current);
// reset the working database
HostApplicationServices.WorkingDatabase = currDb;
}
}
// my code currently
public static void DoSomeWorkExt02(string DwgToProcess)
{
using (Database db = new Database(false, false))
{
db.ReadDwgFile(DwgToProcess, FileOpenMode.OpenForReadAndWriteNoShare, true, "");
{Do Some Work}
db.SaveAs(DwgToProcess, DwgVersion.Current);
}
}
Thanks, Dale.
______________
Yes, I'm Satoshi.