I can reproduce the issue you described. Here is what I did:
1. Write following test code:
namespace MultiDocChanges
{
public class MyCommands
{
[CommandMethod("ChangeDocs")]
public static void RunMyCommand()
{
foreach (Document doc in Application.DocumentManager)
{
using (DocumentLock dlock = doc.LockDocument())
{
AddLineInDrawing(doc);
//Application.ShowAlertDialog("?");
}
}
Autodesk.AutoCAD.Internal.Utils.PostCommandPrompt();
}
private static void AddLineInDrawing(Document dwg)
{
using (Transaction tran = dwg.TransactionManager.StartTransaction())
{
Line line = new Line(new Point3d(1.0,1.0,0.0), new Point3d(20.0, 20.0, 0.0));
line.SetDatabaseDefaults(dwg.Database);
line.Visible = true;
BlockTableRecord model = (BlockTableRecord)tran.GetObject(
SymbolUtilityServices.GetBlockModelSpaceId(dwg.Database), OpenMode.ForWrite);
model.AppendEntity(line);
tran.AddNewlyCreatedDBObject(line, true);
tran.Commit();
}
}
}
} The code is to loop through all drawings opened in AutoCAD and make change to each drawing (adding a line).
2. Start AutoCAD, opened 3 drawings. Before running the code, make sure all drawing is saved. At this stage, I enter (getvar "DBMOD") at command line for each drawing (use Ctrl+Tab, to switch drawing, so that DBMOD would not be changed accidently due to mouse move), I get 0, meaning all 3 drawiing have no change to be saved.
3. Run the code. As result, all 3 drawiings are changed.
4. Close each drawing (clicking "x" on drawing window. Only the current active drawinig prompts for saving change, other drawings simply close (thus, the change made by code is lost.
5. After running the code, instead of closing each drawing, I enter (getvar "DBMOD") at command line (switch to each drawing by Ctrl+Tab), only the drawing that is active when the code is running has DBMOD value being greater than 1, other drawings' DBMOD remain as 0. This explains why saving change is not prompted.
6. Even funny thing is, the line drawn by the code is only visible iin the drawing that is active when the code runs. on other drawings, the line is not visible, nor can be selected by mouse (using selecting window). But, if press Ctrl+A (select all), the line's grips show up (indicating being selected), and quick selecting tool in the property window can also select the invisible line. "regen" command does not bring the line into visible.
7. After running the code, as I said, the drawings that are not active has DBMOD value equal to 0. If I save the drawing anyway (by press Ctrl+S, or "Save" menu), then close the drawiing and reopen it, the invisible line added by the code is now visible, which proves that the code did add a line to the drawing.
So, I'd consider it might be a bug: when the drawing is not current active drawing, The change to the drawing's database somehow does not make it visible. Also, if the database change does not result in graphic change, DBMOD is not updated, thus no saving prompt.