using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestLoad
{
    public class Class1
    {
        [CommandMethod(nameof(Test))]
        public void Test()
        {
            Application.ShowAlertDialog("我来了!!!");
        }
    }
}
  1. DLL文件所在的文件夹路径下新建一个记事本,在记事本中写入以下内容:

(command “netload” “E:\Guo\CadDevelopment\TestLoad\bin\Debug\TestLoad.dll”)

  1. 保存后缀lsp,Test.lsp
    在这里插入图片描述

  2. 打开Cad,点击工具=>加载应用程序
    在这里插入图片描述

  3. 点击 启动组=>添加=>点击Test.lsp=>打开
    在这里插入图片描述

  4. 现在输入 Test 就好了
    在这里插入图片描述

遇到错误

今天踩坑(2023.7.12) 路径一定要是全英文,不然乱码,还有就是

(command “netload” “E:\Guo\CadDevelopment\TestLoad\bin\Debug\TestLoad.dll”)

这里不要有多余的空格或换行,
多余的空格或换行:AutoCAD 对命令输入的空格和换行符非常敏感,确保命令及其参数之间没有多余的空格或换行符。

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐