本帖最后由 Real_King 于 2015-6-10 09:38 编辑
- private void OKButton_Click(object sender, EventArgs e)//确定按钮
- {
- // 获得当前文档和数据库 Get the current document and database
- Document acDoc = AcadApp.DocumentManager.MdiActiveDocument;
- Database acCurDb = acDoc.Database;
- // 启动一个事务 Start a transaction
- using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
- {
- // 以只读方式打开块表 Open the Block table for read
- BlockTable acBlkTbl;
- acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
- OpenMode.ForRead) as BlockTable;
- // 以写方式打开模型空间块表记录 Open the Block table record Model space for write
- BlockTableRecord acBlkTblRec;
- acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
- OpenMode.ForWrite) as BlockTableRecord;
- // 创建一个中心点在 (2,3,0) ,半径为4.25 的圆 Create a circle that is at 2,3 with a radius of 4.25
- Circle acCirc = new Circle();
- acCirc.SetDatabaseDefaults();
- acCirc.Center = new Point3d(2, 3, 0);
- acCirc.Radius = 4.25;
- // 添加新对象到块表记录和事务中 Add the new object to the block table record and the transaction
- acBlkTblRec.AppendEntity(acCirc);
- acTrans.AddNewlyCreatedDBObject(acCirc, true);
- // 保存新对象到数据库中 Save the new object to the database
- acTrans.Commit();
- }
- }
代码应该是没有问题的,但是,就是在这个Form里,对实体提交的编辑事务都没有效果,奇怪了!测试过其它按钮或者画其它实体,都无效!改变颜色等等都没效果-----------------------已解决,ShowModalDialog那个最外层事务没提交,WTF
|