patrickcraig31 发表于 2018-8-29 10:40:03

打开文档时运行代码

您好,
有谁知道如何使用打开文档的事件来运行代码?我想在每次打开文档时加载 cuix 文件。
**** Hidden Message *****

kpblc 发表于 2018-8-29 11:39:34

你是说
https://www.google.com/search?q=autocad+.net+iextensionapplication&ie=utf-8&oe=utf-8&client=firefox-b-ab
https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2017/ENU/AutoCAD-NET/files/GUID-FA3B4125-F7BD-4E89-969F-9DCC90AC6977-htm.html
http://through-the-interface.typepad.com/through_the_interface/2006/09/initialization_.html
吗?

Keith™ 发表于 2018-8-29 19:17:16

上面提到的几种方法你没有说什么语言,所以我会提供 VB.Net首先你需要捕获文档集合。要利用现有事件,只需像这样声明变量 WithEvents(公共或私有,视情况而定)您需要将其设置为类中的全局变量 Private WithEvents docManager = Autodesk.AutoCAD.ApplicationServices.DocumentCollection现在您可以捕获这样的文档事件:Private Sub docManager_DocumentActivated(sender as Object, e As DocumentCollectionEventArgs) Handles docManager.DocumentActivated。
'DoStuffHere。
结束子。

Private Sub docManager_DocumentCreated(sender as Object, e As DocumentCollectionEventArgs) Handles docManager.DocumentCreated。
'DoStuffHere。
结束子。

kpblc 发表于 2018-8-30 08:51:38

您还可以使用PerDocData属性
http://www.keanw.com/2014/04/per-document-data-in-autocad-net-applications-part-3.html
页: [1]
查看完整版本: 打开文档时运行代码