netload不能弹出对话框,参考文献2
参考文献1说明了自定义菜单的问题,用的是cad的系统命令
只要加载了dll,自定义的命令与cad的命令同等地位。
这时,可以将自定义菜单的系统命令替换为自定义命令。
<CommandMethod("AddMenu")>
Public Sub AddMenu()
Dim currentPath1 As String = System.Environment.CurrentDirectory
Dim currentPath As String = "D:\testVBNet\ODPM"
Dim cs As CustomizationSection = activeDoc.AddCui(cuiFile, menuGroupName)
cs.AddMacro("面板", "^C^C_CreatePalette1 ", "ID_MyPalette", "创建面板: CreatePalette1", currentPath & "\Image\Line.BMP")
cs.AddMacro("多段线", "^C^C_Pline ", "ID_MyPLine", "创建二维多段线: PLINE", currentPath & "\Image\Polyline.BMP")
cs.AddMacro("矩形", "^C^C_Rectang ", "ID_MyRectang", "创建矩形多段线: RECTANG", currentPath & "\Image\Rectangle.BMP")
cs.AddMacro("圆", "^C^C_circle ", "ID_MyCircle", "用指定半径创建圆: CIRCLE", currentPath & "\Image\Circle.BMP")
cs.AddMacro("复制", "^C^CCopy ", "ID_MyCopy", "复制对象: COPY", currentPath & "\Image\Copy.BMP")
cs.AddMacro("删除", "^C^CErase ", "ID_MyErase", "从图形删除对象: ERASE", currentPath & "\Image\Erase.BMP")
cs.AddMacro("移动", "^C^CMove ", "ID_MyMove", "将对象在指定方向上平移指定的距离: MOVE", currentPath & "\Image\Move.BMP")
cs.AddMacro("旋转", "^C^CRotate ", "ID_MyRotate", "绕基点旋转对象: ROTATE", currentPath & "\Image\Rotate.BMP")
Dim sc As StringCollection = New StringCollection()
sc.Add("MyPop1")
Dim myMenu As PopMenu = cs.MenuGroup.AddPopMenu("我的菜单", sc, "ID_MyMenu")
If myMenu IsNot Nothing Then
myMenu.AddMenuItem(-1, "面板", "ID_MyPalette")
myMenu.AddMenuItem(-1, "多段线", "ID_MyPLine")
myMenu.AddMenuItem(-1, "矩形", "ID_MyRectang")
myMenu.AddMenuItem(-1, "圆", "ID_MyCircle")
myMenu.AddSeparator(-1)
Dim menuModify As PopMenu = myMenu.AddSubMenu(-1, "修改", "ID_MyModify")
menuModify.AddMenuItem(-1, "复制", "ID_MyCopy")
menuModify.AddMenuItem(-1, "删除", "ID_MyErase")
menuModify.AddMenuItem(-1, "移动", "ID_MyMove")
menuModify.AddMenuItem(-1, "旋转", "ID_MyRotate")
End If
cs.LoadCui()
End Sub
如果发现菜单一直没有更新,额可以将自定义的cuix文件删除,重新加载
自动加载dll的方法见参考文献7
至此VB.net开发CAD所有关节全部打通。
正式进入实际编程阶段。
相对于VBA,VB.net更为灵活,做出的东西更像一个产品。
参考文献
vbnet 实现AutoCAD自定义菜单和工具栏_vb,net 开发cad 添加菜单栏下拉子菜单-CSDN博客
AutoCAD输入netload命令后不弹出菜单而是一直显示程序集文件名解决方案-CSDN博客
https://www.cnblogs.com/loveclumsybaby/archive/2012/08/21/2649050.html
AutoCAD中.Net实现打开程序自动加载菜单栏的方法_cad二开自动加载按钮-CSDN博客
https://www.cnblogs.com/bomb12138/p/3607929.html
https://www.cnblogs.com/bomb12138/p/3600842.html
cad二次开发——自动运行dll,加载菜单(收集)_cad开启自动加载dll-CSDN博客