1、创建 C#控制台程序;
2、增加引用:


3、代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using AutoCAD;
namespace TestCAD
{
class Program
{
static void Main(string[] args)
{
List<AcadApplication> vec = new List<AcadApplication>();
for(int i=0;i<3;++i)
{
var tmp = new AcadApplication();
tmp.Visible = true;
vec.Add(tmp);
}
Thread.Sleep(10000);
int nlen = vec.Count;
for(int i=0;i<nlen;++i)
{
AcadDocument doc = vec[i].ActiveDocument;
doc.SendCommand("regen\n");
}
}
}
}

这篇博客展示了如何创建一个C#控制台程序,引用AutoCAD库,并同时打开多个AutoCAD应用程序实例。代码中,程序会打开3个AutoCAD应用,使其可见,然后在每个应用中执行' regen '命令进行文档刷新。这个例子适用于需要批量处理AutoCAD文档或者进行自动化操作的场景。
1万+

被折叠的 条评论
为什么被折叠?



