Create Menus with lisp
Here is an example of how to create a menu and populate it on the fly with lisp and Bricscad V10
Enjoy
;;;-===-==-==-==-=-==-==-==-=-==-==-=-==-==-=-==-==-=-==-==-=-==-=-==-
;;;(Menu:loadDynamicPopUpMenu '("Mymen&u" (
;;; ("&Do Command1" . "command1")
;;; ("D&o Command2" . "command2")
;;; ("Do &Command3" . "command3")
;;;)))
;;;-===-==-==-==-=-==-==-==-=-==-==-=-==-==-=-==-==-=-==-==-=-==-=-==-
(defun Menu:loadDynamicPopUpMenu (menulist /
acadapp cmd
currmenugroup
doc loadedmenulist
menu newmenu
)
(vl-load-com)
(setq acadapp (vlax-get-acad-object)
loadedmenulist '()
doc (vla-get-activedocument acadapp)
currmenugroup (vla-item (vla-get-menugroups
(vla-get-application doc)
)
"BRICSCAD"
)
)
(if (/= currmenugroup nil)
(progn
(vlax-for menu (vla-get-menus currmenugroup)
(setq loadedmenulist
(cons
(vla-get-namenomnemonic menu)
loadedmenulist
)
)
)
(if (= (vl-position (car menulist) loadedmenulist) nil)
(progn
(setq newmenu (vla-add (vla-get-menus currmenugroup)
(car menulist)
)
)
(foreach e (car (cdr menulist))
(vla-addmenuitem
newmenu
(1+ (vla-get-count newmenu))
(car e)
(cdr e)
)
)
(vla-insertinmenubar
newmenu
(1+ (vla-get-count
(vla-get-menubar acadapp)
)
)
)
)
(princ (strcat "\nerror: "
(car menulist)
" menu is already loaded "
)
)
)
)
)
(princ)
)
0