- [CommandMethod("tt", CommandFlags.Session)]
- public static void Test()
- {
- string strTemplatePath = "acad.dwt";
- DocumentCollection acDocMgr = Application.DocumentManager;
- Document acDoc = acDocMgr.Add(strTemplatePath);
- //acDocMgr.MdiActiveDocument = acDoc;
- Database db = acDoc.Database;
- using (acDoc.LockDocument())
- {
- using (Transaction trans = db.TransactionManager.StartTransaction())
- {
- BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
- BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
- Circle cir = new Circle(new Point3d(1, 1, 0), Vector3d.ZAxis, 1.0);
- btr.AppendEntity(cir);
- trans.AddNewlyCreatedDBObject(cir, true);
- trans.Commit();
- }
- }
- }
|