harrison-matt Posted November 19, 2010 Posted November 19, 2010 All, I am wondering how difficult it would be to add a menu to the menu bar using visual lisp. I have an enterprise CUI on many users computers and several users don't have the menu from that CUI on thier menubar. Instead of going through the CUI and editing thier workspace i want to add the menu using Visual Lisp. I know that this should be possible using, InsertInMenuBar and the PopupMenu object. I am not sure how to access the specific menu. Any suggestions or solutions? Thanks, Matt Quote
Guest kruuger Posted November 19, 2010 Posted November 19, 2010 maybe this. just edit the list and extension (cui or cuix) (defun LOADMENU (/ ERR OLDCMD) (setq OLDCMD (getvar "cmdecho")) (setvar "cmdecho" 0) (foreach MenuName (list "Adservco_2010" "Kojacek_2010" "Tools_2010") (if (not (menugroup MenuName)) (if (findfile (strcat MenuName ".cuix")) (progn (command "_cuiload" MenuName) (princ (strcat "\n>> Menu [" MenuName "] loaded.")) ) (if (not ERR) (setq ERR (strcat "\n- " MenuName)) (setq ERR (strcat ERR "\n- " MenuName)) ) ) ) ) (if ERR (alert (strcat "\nCan't find partial menu:" ERR)) ) (setvar "cmdecho" OLDCMD) (princ) ) (LOADMENU) (princ) Quote
rkmcswain Posted November 19, 2010 Posted November 19, 2010 This includes no error handling, and just the bare bones, but it should help you get started. ; Get AutoCAD (setq *acad* (vlax-get-acad-object)) ; Get the loaded menugroups (setq *mgs* (vla-get-Menugroups *acad*)) ; Get a particular menugroup (setq *menu* (vlax-invoke-method *mgs* "Item" 0)) ; Get the menus in this menugroup (setq *pops* (vla-get-menus *menu*)) ; Get a particular menu (setq *pop* (vlax-invoke-method *pops* "Item" 5)) ; Insert it (vla-InsertInMenuBar *pop* 5) Quote
Ahankhah Posted September 27, 2011 Posted September 27, 2011 This includes no error handling, and just the bare bones, but it should help you get started. ; Get AutoCAD (setq *acad* (vlax-get-acad-object)) ; Get the loaded menugroups (setq *mgs* (vla-get-Menugroups *acad*)) ; Get a particular menugroup (setq *menu* (vlax-invoke-method *mgs* "Item" 0)) ; Get the menus in this menugroup (setq *pops* (vla-get-menus *menu*)) ; Get a particular menu (setq *pop* (vlax-invoke-method *pops* "Item" 5)) ; Insert it (vla-InsertInMenuBar *pop* 5) The code works nice in 4 first lines, but there is a problem running this line: (setq *pop* (vlax-invoke-method *pops* "Item" 5)) Visual LISP returns this error message: ; error: Automation Error. Invalid argument index in ItemWho knows what is wrong with my understanding or the code of rkmcswain? P.S. I tried also numbers other than 5 with no success. Quote
rkmcswain Posted September 27, 2011 Posted September 27, 2011 Walk through the code one line at a time and validate each variable. It sounds like whatever *pops* is, doesn't have an item 5. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.