//CommandFlags.Session Session states that the command //will run on all documents in the session - instead of //just the calling doc. [CommandMethod("cdb",CommandFlags.Session)] public void cdb() { //create new database DocumentCollection docs = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager; //I think you should be able to add the new database to the current session //via the overloads for Database(...) but I didn't get it to work. Didn't try //to hard though. So I just open it below. Database ndb = new Database(); ndb.SaveAs(@"c:\temp.dwg", DwgVersion.Current); ndb.Dispose(); //open doc making it the active document Document newDoc = Application.DocumentManager.Open(@"C:\temp.dwg", false); //Before any editing can be done on a doc it needs to be locked. This is //done automatically on the calling doc. Any others need to be locked //manually. Comment it out and you'll see the boom! newDoc.LockDocument(); Database db = Application.DocumentManager.MdiActiveDocument.Database; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; Point3d startpt = new Point3d(4.0, 2.0, 0.0); Point3d endpt = new Point3d(10.0, 7.0, 0.0); Line line = new Line(startpt, endpt); using (Transaction tr = ed.Document.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); ObjectId blkRecId = bt[BlockTableRecord.ModelSpace]; BlockTableRecord btr = (BlockTableRecord)tr.GetObject(blkRecId, OpenMode.ForWrite); btr.AppendEntity(line); tr.AddNewlyCreatedDBObject(line, true); tr.Commit(); } }