using System; using System.Collections.Generic; using System.Linq; using System.Text; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.EditorInput; namespace InitAndOpt { public class InitClass : IExtensionApplication { //程序的初始化 public void Initialize() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; //在AutoCAD命令行载入信息,它们会在程序载入时显示 ed.WriteMessage("程序开始初始化"); } //程序的终止化清理工作 public void Terminate() { System.Diagnostics.Debug.WriteLine("程序结束,你可以做一些清理工作"); } //注册一个命令 [CommandMethod ("InitCommand")] public void InitCommand() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage("测试初始化..."); } } }
同样的,需要设置用frame work 3.5编译以及引用两个程序集且要添加三个命名空间
<<<<<<end>>>>>>