public class Command_test { [CommandMethod("tt", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw)] public static void tt() { Database db = HostApplicationServices.WorkingDatabase;//当前的数据库 Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; int aa = 0; for (int i = 0; i < 50; i++) { using (Transaction tr = db.TransactionManager.StartTransaction()) { //新建圆 var ent = EntityAdd.AddCircleToEntity(new Point3d(aa++, 0, 0), 0.5); EntityAdd.AddEntityToMsPs(tr, db, ent); //刷新内容 Application.UpdateScreen(); tr.Commit(); } ed.WriteMessage(aa++.ToString()+"\n");//这两种不同感觉 //ed.WriteMessage(aa++.ToString()+"\r");//这两种不同感觉 //高版本要加这句令命令栏立即执行 System.Windows.Forms.Application.DoEvents(); //阻塞 System.Threading.Thread.Sleep(100); } } }
代码效果: