Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
My code is working but I get "Warning: An error occured during save. We recommend that you run Recover".
I'm attaching the code and an empty dwg file that is causing the issue. I believe it was created by microstation - not sure if that makes any difference.
A second question: after db.SaveAs, why does autocad still tell me that "This DWG file was saved by an application that was not developed or licensed by Autodesk"?
string msg = "rename, change units"; string docpath = "\\some path\\"; string oldname = "unitstest.dwg"; string newname = "unitstest_new.dwg"; Database curdb = acdb.HostApplicationServices.WorkingDatabase; try { using (Database db = new Database(false, true)) { db.ReadDwgFile(docpath + oldname, FileOpenMode.OpenForReadAndAllShare, false, ""); db.CloseInput(true); HostApplicationServices.WorkingDatabase = db; using (Transaction tr = db.TransactionManager.StartTransaction()) { db.Insunits = UnitsValue.Meters; tr.Commit(); }// using tr db.SaveAs(docpath + newname, DwgVersion.Current); HostApplicationServices.WorkingDatabase = curdb; }// using new database }// try catch (System.Exception ex) { msg += "\nError:\n" + ex.Message; }
Solved! Go to Solution.