这样启动时加载菜单
我把菜单代码写在一个函数里面了,怎样启动cad时自动调用那个函数呢,我没有用com接口,用继承 Implements Application.IExtensionApplication.Initialize的方法就不行
纯.net情况下应该怎么处理啊?
你的菜单代码是用什么实现的?Ribbin?请贴上 雪山飞狐_lzh 发表于 2015-4-3 12:30 static/image/common/back.gif
你的菜单代码是用什么实现的?Ribbin?请贴上
<CommandMethod("AA")>
Sub AA()
Dim MenuGroup As Object = Nothing
Dim Menu As Object
Try
MenuGroup = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication.MenuGroups.Item(0)
Menu = MenuGroup.Menus.Item("AA")
Catch ex As System.Exception
Menu = MenuGroup.Menus.Add("AA")
Menu.AddMenuItem(0, "a1", "_A1 ")
Menu.AddMenuItem(1, "a2", "_A2 ")
End Try
Try
MenuGroup.Menus.InsertMenuInMenuBar("AA", "编辑(&E)")
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub 你这就是引用com库的方式
试下我刚发的代码吧
<Assembly: ExtensionApplication(GetType(Cadd.TlsApplication))>
Namespace Cadd
Class TlsApplication
Implements IExtensionApplication
Sub Initialize() Implements IExtensionApplication.Initialize
CadD.Start()
End Sub
Sub Terminate() Implements IExtensionApplication.Terminate
End Sub
End Class
Public Class CadD
Public Shared Sub Start()
AA()
End Sub
Public Shared Sub AA()
Dim MenuGroup As Object = Nothing
Dim Menu As Object
Try
MenuGroup = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication.MenuGroups.Item(0)
Menu = MenuGroup.Menus.Item("AA")
Catch ex As System.Exception
Menu = MenuGroup.Menus.Add("AA")
Menu.AddMenuItem(0, "a1", "_A1 ")
Menu.AddMenuItem(1, "a2", "_A2 ")
End Try
Try
MenuGroup.Menus.InsertMenuInMenuBar("AA", "编辑(&E)")
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
End Namespace 用局部cui要简单些 把菜单。共工具栏之类的先做好 这是推荐方式 slw7310 发表于 2015-4-3 19:38 static/image/common/back.gif
Namespace Cadd
Class TlsApplication
Implements IExtensionApplication
我增加了Class TlsApplication,但是用netload命令加载dll后,Initialize()方法没有运行。没能加载菜单。 试下这里的代码吧
http://bbs.mjtd.com/thread-113389-1-1.html 解决了,原来的方法可以,我把类分开就可以了。谢谢!
页:
[1]