动图演示
实现代码
#if !HC2020
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using Acap = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.AutoCAD.ApplicationServices;
#else
using GrxCAD.DatabaseServices;
using GrxCAD.EditorInput;
using GrxCAD.Geometry;
using GrxCAD.Runtime;
using Acap = GrxCAD.ApplicationServices.Application;
using GrxCAD.ApplicationServices;
#endif
namespace JoinBox.src.试验库
{
public class Command_test
{
[CommandMethod("tt1", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw)]
public static void tt1()
{
// 获取当前文档和数据库
Document doc = Acap.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = Acap.DocumentManager.MdiActiveDocument.Editor;
// 启动事务
using (Transaction tr = db.TransactionManager.StartTransaction())
{
// 块表
var acBlkTbl = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
// 当前空间的块表记录
var acBlkTblRec = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
int aa = 0;
for (int i = 0; i < 25; i++)
{
//新建圆
var acCirc = new Circle(new Point3d(aa++, 0, 0), Vector3d.ZAxis, 0.5);
// 将新对象添加到块表记录和事务
acBlkTblRec.AppendEntity(acCirc);
tr.AddNewlyCreatedDBObject(acCirc, true);
//刷新内容
acCirc.Draw();
Acap.UpdateScreen();
//输出到命令栏,注意一下这两种不同感觉
ed.WriteMessage(aa.ToString() + "
");
//ed.WriteMessage(aa.ToString()+"
");
//阻塞线程
System.Threading.Thread.Sleep(100);
}
//提交事务
tr.Commit();
}
}
}
}
Arx同等效果
e大也写了一篇: ObjectARX延时动画效果简单示意
(完)