谢谢我知道了 Database db = Application.DocumentManager.MdiActiveDocument.Database; DBTransMan tm = db.TransactionManager;
MText txt = new MText(); txt.Contents = "123\r\n456\r\n测试"; using(Transaction ta = tm.StartTransaction()) { BlockTable bt = (BlockTable)tm.GetObject(db.BlockTableId, OpenMode.ForRead); ObjectId objid; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; if (bt.Has("A010001")) { objid = bt["A010001"]; BlockTableRecord btr = (BlockTableRecord)tm.GetObject(objid, OpenMode.ForWrite); btr.AppendEntity(txt); tm.AddNewlyCreatedDBObject(txt, true); ed.WriteMessage(btr.Name + " --- Renaud");
ta.Commit(); } else { ed.WriteMessage("Not Has --- Renaud"); } } |