So with what Mick and Glenn said; Use Database to open drawings and make changes.
And what Alexander reminded me of what Tony said; Make sure that the Database you want to change is the current working database.
I came up with this (just a section of the code) that seems to be working correctly. Is this a safe way to do it?
Any comments/suggestions welcomed. Thanks in advance, and thanks for the help so far.
foreach (string Str in DwgList) {
bool ShouldSave = false;
//Database db = new Database (false, true);
try {
using (Database db = new Database (false, true)) {
db.ReadDwgFile (Str, System.IO.FileShare.Read, true, null);
if (db != HostApplicationServices.WorkingDatabase) {
HostApplicationServices.WorkingDatabase = db;
}
if (HasLayer (db, "Cloud-UNKNOWN")) {
string Rev = (GetHighestRev(db));
if (Rev != "") {
UpdateRevBlock (db, Rev);
UpdateCloudLayer (db, "Cloud-UNKNOWN", "Cloud-" + Rev);
ShouldSave = true;
//MessageBox.Show ("Right before save.");
}
}
if (ShouldSave == true) {
db.RetainOriginalThumbnailBitmap = true;
db.SaveAs (Str, DwgVersion.Current);
SaveAr[SaveCnt] = Str;
++SaveCnt;
}
else {
DiscardAr[DiscardCnt] = Str;
++DiscardCnt;
}
//db.Dispose();
}
}
catch {
CannotOpenAr[CannotOpenCnt] = Str;
++CannotOpenCnt;
}
}