That is exactly what I want Mark, thanks.
Still crashing trying to save it, however
static void db_WblockNotice(object sender, WblockNoticeEventArgs e)
{
Microsoft.Win32.RegistryKey regkey=Microsoft.Win32.Registry.CurrentUser.OpenSubKey
(Autodesk.AutoCAD.Runtime.SystemObjects.DynamicLinker.ProductKey);
Microsoft.Win32.RegistryKey wblockreg=regkey.OpenSubKey
(@"Profiles\" +acadApp.GetSystemVariable("Cprofile").ToString()+@"\Dialogs\write_block_dialog");
string sFile=wblockreg.GetValue("MRUPathListItem0").ToString();
// MessageBox.Show(wblockreg.GetValue("MRUPathListItem0").ToString());
Editor ed = acadApp.DocumentManager.MdiActiveDocument.Editor;
using(Database wblockDatabase = new Database(false, true))
{
try
{
wblockDatabase.ReadDwgFile(sFile, System.IO.FileShare.ReadWrite, true, null);
if (wblockDatabase != HostApplicationServices.WorkingDatabase)
HostApplicationServices.WorkingDatabase = wblockDatabase;
wblockDatabase.SaveAs(sFile, DwgVersion.AC1800a); //2004 final
//wblockDatabase.SaveAs(sFile, DwgVersion.AC1500);
}
catch (Autodesk.AutoCAD.Runtime.Exception acEx)
{
ed.WriteMessage("{0}AutoCAD Runtime Exception: {1}", Environment.NewLine, acEx.Message);
return;
}
catch (System.Exception ex)
{
ed.WriteMessage("{0}System Runtime Exception: {1}", Environment.NewLine, ex.ToString());
return;
}
finally
{
}
}
}
The error is eInvaliddrawingversion , however when I use "wblockDatabase.SaveAs(sFile, DwgVersion.Current);" there is no error reported and it crashes