AutoCAD 调用类库时,自动执行用户自定义方法

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;

[assembly: ExtensionApplication(typeof(AutoLoadApplication.Initiallization))] //扩展
[assembly: CommandClass(typeof(AutoLoadApplication.Autoload))]
namespace AutoLoadApplication
{
    public class Initiallization : Autodesk.AutoCAD.Runtime.IExtensionApplication //当调用类库时,自动加载执行
    {
        public void Initialize()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            ed.WriteMessage("自动加载,进行初始化!");
        }
        public void Terminate()
        {
            Console.WriteLine("清理!");
        }
    }

    public class Autoload
    {
        [CommandMethod("Test")]
        public void Test()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            ed.WriteMessage("这是一个Test命令!");
        }
    }
}

你可能感兴趣的:(自定义方法)