AutoCAD二次开发系列教程01-如何在AutoCAD中输出Hello World

发布时间 2023-05-05 08:35:43作者: jiangyong1995

目录

01项目环境准备

02代码示例

03输出示例


01项目环境准备

A.建立依赖的本地库(提前从AutoCAD软件安装目录拷贝开发时需要使用的库,如:accoremgd.dll)

image

B.创建新的类库(.Net Framework),注意不同AutoCAD版本对应不同Framework版本,当前案例使用AutoCAD2016对应Framework4.5.2

image
image

C.建立类文件,创建命令函数,使用CAD库中的特性标记命名空间与函数

using Autodesk.AutoCAD.ApplicationServices.Core;
using Autodesk.AutoCAD.Runtime;

[assembly: CommandClass(typeof(Hello.Cad.App01.Class1))]
namespace Hello.Cad.App01
{
    public class Class1
    {
        [CommandMethod("funKey")]
        public void Function1()
        {
            Application.ShowAlertDialog("Hello World!!!");
        }
    }
}

https://gitee.com/jiangyong95/BlogCAD