- 积分
- 6614
- 明经币
- 个
- 注册时间
- 2006-8-30
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2014-12-4 14:46:11
|
显示全部楼层
本帖最后由 cheng5276 于 2014-12-4 15:10 编辑
谢谢老大,不过好像不管用,鉴于我对老大的指点出现了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++选择模式++");
}
}
}
理解二 (只要新建或切换文档 立马致命错误)
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++选择模式++");
}
}
}
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|