Code Red > AutoLISP (Vanilla / Visual)
menu swapping
wizman:
hi guys,
we are trying to have a program for menu swapping in our company, but we
encountered that using this code:
(command "_.menuload" "L:\\DWG-LIB\\Global\\myown.cui")
loads the cui, but the problem is it cant be seen on the menubar. but when we checked the
menus in menuload dialog box, its already there.
i think i should be using these next two functions but dont know how to use these ones because
i cant find it on my help file.
vla-get-onmenubar
vla-insertmenuinmenubar
any ideas or discussion you can direct us anyone?many thanks in advance
ronjonp:
Take a look at MENUCMD.
wizman:
thanks ronjonp, i tried menucmd also but still not showing in my menu bar, i finally found vla-get-onmenubar on my help file but directed me to a vba solution (as seen below)
--- Quote ---Sub Example_OnMenuBar()
' This example creates a new menu called TestMenu and inserts a menu item
' into it. The menu is then displayed on the menu bar, and then
' removed from the menu bar.
Dim currMenuGroup As acadMenuGroup
Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
' Create the new menu
Dim newMenu As AcadPopupMenu
Set newMenu = currMenuGroup.Menus.Add("TestMenu")
' Add a menu item to the new menu
Dim newMenuItem As AcadPopupMenuItem
Dim openMacro As String
' Assign the macro string the VB equivalent of "ESC ESC _open "
openMacro = Chr(3) & Chr(3) & Chr(95) & "open" & Chr(32)
Set newMenuItem = newMenu.AddMenuItem(newMenu.count + 1, "Open", openMacro)
' Display the menu on the menu bar
newMenu.InsertInMenuBar (ThisDrawing.Application.MenuBar.count + 1)
GoSub QUERYMENU
' Remove the menu from the menu bar
currMenuGroup.Menus.RemoveMenuFromMenuBar ("TestMenu")
GoSub QUERYMENU
Exit Sub
QUERYMENU:
If newMenu.OnMenuBar Then
MsgBox "The menu called " & newMenu.name & " is on the menu bar."
Else
MsgBox "The menu called " & newMenu.name & " is not on the menu bar."
End If
Return
End Sub
--- End quote ---
this one works fine also except that i cant see the menu on the menu bar.
--- Code: ---(defun c:test ()
(setq acad_app (vlax-get-acad-object))
(setq curr_doc (vla-get-activeDocument acad_app))
(setq all_menus (vla-get-menuGroups acad_app))
(vlax-for n all_menus
(if (= (vla-get-name n) "myown")
(setq flag T)
)
(terpri)
(princ (vla-get-name n))
)
(if (null flag)
(vla-load all_menus "myown.cui")
)
)
--- End code ---
T.Willey:
Here is some of my code for my menu setup.
--- Code: ---(defun MyErrorCheck (Function Listof / ErrChk)
; Use just like (vl-catch-all-apply....
; Returns nil if an error
(setq ErrChk (vl-catch-all-apply Function Listof))
(if (vl-catch-all-error-p ErrChk)
(setq ErrChk nil)
ErrChk
)
)
;---------------------------------------------
(setq AcadObj (vlax-get-Acad-Object))
(setq MnGrp (vla-get-MenuGroups AcadObj))
(if (not (MyErrorCheck 'vla-Item (list MnGrp "custom")))
(vla-Load MnGrp "C:/MyCustom/Menus/custom.mns")
)
(if (not (setq MnObj (MyErrorCheck 'vla-Item (list MnGrp "custom2"))))
(setq MnObj (vla-Load MnGrp "C:/MyCustom/Menus/custom2.mns"))
(setq MnObj (vla-Item MnGrp "custom2"))
)
(setq MnBar (vla-get-MenuBar AcadObj))
(if
(or
(not (setq MyMenu (MyErrorCheck 'vla-Item (list MnBar "My&Custom"))))
(and
(/= (vla-get-Name (vla-Item MnBar (- (vla-get-Count MnBar) 2))) "My&Custom")
(not (vla-RemoveFromMenuBar MyMenu))
)
)
(vla-InsertInMenuBar
(vla-Item (vla-get-Menus MnObj) "My&Custom")
(1- (vla-get-Count MnBar))
)
)
--- End code ---
wizman:
thanks mr t.wiley, ill try your way tomorrow morning. :-)
Navigation
[0] Message Index
[#] Next page
Go to full version