|
发表于 2014-12-4 14:46:00
|
显示全部楼层
谢谢老大,不过好像不管用,鉴于我对老大的指点出现了2种理解,均未成功,恭请继续指点.....
理解一:(依然只是在新建文件时只执行了一次)
using Autodesk.AutoCAD.Runtime;
using System;
using Application = Autodesk.AutoCAD.ApplicationServices.Application;
using Document = Autodesk.AutoCAD.ApplicationServices.Document;
namespace ClassLibrary1
{
public class Main : IExtensionApplication
{
Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
public void Initialize()
{
Application.DocumentManager.MdiActiveDocument.ImpliedSelectionChanged += new EventHandler(doc_ImpliedSelectionChanged);
ed.WriteMessage("\n+++初始化成功+++");
}
public void Terminate() { } //释放初始化,即CAD退出时才会执行
public void doc_ImpliedSelectionChanged(object sender, EventArgs e)
{
ed.WriteMessage("\n++选择模式++");
}
}
}
理解二 (只要新建或切换文档 立马致命错误)
owg0fm1mrc0.jpg
using Autodesk.AutoCAD.Runtime;
using System;
using Application = Autodesk.AutoCAD.ApplicationServices.Application;
using Document = Autodesk.AutoCAD.ApplicationServices.Document;
using Autodesk.AutoCAD.ApplicationServices;
namespace ClassLibrary1
{
public class Main : IExtensionApplication
{
Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
public void Initialize()
{
Application.DocumentManager.DocumentCreated += new DocumentCollectionEventHandler(DocumentManager_DocumentCreated);
Application.DocumentManager.DocumentActivated += new DocumentCollectionEventHandler(DocumentManager_DocumentActivated);
Application.DocumentManager.MdiActiveDocument.ImpliedSelectionChanged += new EventHandler(doc_ImpliedSelectionChanged);
Application.DocumentManager.MdiActiveDocument.ImpliedSelectionChanged += new EventHandler(doc_ImpliedSelectionChanged);
ed.WriteMessage("\n+++初始化成功+++");
}
public void Terminate() { } //释放初始化,即CAD退出时才会执行
public void DocumentManager_DocumentCreated(object sender, EventArgs e)
{
Application.DocumentManager.MdiActiveDocument.ImpliedSelectionChanged += new EventHandler(doc_ImpliedSelectionChanged);
}
public void DocumentManager_DocumentActivated(object sender, EventArgs e)
{
Application.DocumentManager.MdiActiveDocument.ImpliedSelectionChanged += new EventHandler(doc_ImpliedSelectionChanged);
}
public void doc_ImpliedSelectionChanged(object sender, EventArgs e)
{
ed.WriteMessage("\n++选择模式++");
}
}
} |
|