Hello, I'm trying to modify the POP502 popupmenu and only that one. I've found some code one Afralisp site, and on Autocad 2000 VBA programmation manual But i don't find solution to clearely identify which popup is my "command edition contextual menu" (the pop502 one) I don't want to modify the POP0 one.
The other problem is that the POP502 don't have the Shortcutmenu = True until the user has activate it one time !!
Is there is someone that now how to get the "label" or "Alias" (POP502.CMEDIT) of a popupmenu ?
Thanks a lot Gérald Lemoine
PS: I place there the code that i've made: It works, but i'me never shure of the menu i modify !
;**************************************************************************** ;§/menu/add an item to a contextual menu/pos StrItem StrMacro AddSeparator ;;pos = integer for Menuitem position. Pos = 0 ad ythe beginning ;;StrItem = string label of item ;;StrMacro = String macro associated to item ;;Addseparator nil : none , T : before & after , 1 after , 0 before
(defun pw_addItem2ContextualMenu ( pos StrItem StrMacro AddSeparator / ok i j acadObject AcadMenuGroup NbMenuGroup currMenuGroup currMenuGroupMenus scMenu AlreadyExist)
;;sous-commande pour tester la pré-existance de l'entrée de menu ;;---------------------------------- (defun AlreadyExist (popMenu label / k nb Oui ssMenu) (setq nb (vlax-get-property popMenu 'Count)) ;;parcours le menus pour trouver le même label (setq k 0) (while (and (< k nb) (not oui)) (setq ssMenu (vlax-invoke-method popMenu 'Item k )) ;;(vlax-invoke-method id 'Delete ) (if (= label (vlax-get-property ssMenu 'label)) (setq Oui T ) ) (setq k (+ 1 k)) ) Oui ) ;;----------------------------------
(vl-Load-Com) (setq acadObject (vlax-get-acad-object)) (setq AcadMenuGroup (vla-get-MenuGroups acadObject)) (setq NbMenuGroup (vlax-get-property AcadMenuGroup 'Count))
(setq j 0)
(while (and (< j NbMenuGroup) (not ok)) (setq currMenuGroup (vlax-invoke-method AcadMenuGroup 'Item j )) (setq currMenuGroupMenus (vla-get-Menus currMenuGroup)) (setq nb (vlax-get-property currMenuGroupMenus 'Count)) ;;parcours les menus pour trouver celui qui est contextuel (setq i 0) (while (and (< i nb) (not ok)) (setq scMenu (vlax-invoke-method currMenuGroupMenus 'Item i )) (if (= ':VLAX-TRUE (vlax-get-property scMenu 'ShortcutMenu)) (setq ok T ) ) (setq i (+ 1 i)) ) (setq j (+ 1 j)) )
(if ok (progn (prompt "\nFinded contextual menu") ;;verifie si item n'existe pas, et ajoute l'item (if (not (AlreadyExist scMenu StrItem)) (progn (vlax-invoke-method scMenu 'AddMenuItem pos StrItem StrMacro) (cond ((= Addseparator T) (vlax-invoke-method scMenu 'AddSeparator pos) (vlax-invoke-method scMenu 'AddSeparator (+ pos 1)) ) ((= Addseparator 1) (vlax-invoke-method scMenu 'AddSeparator (+ pos 1)) ) ((= Addseparator 0) (vlax-invoke-method scMenu 'AddSeparator pos) ) ) ;;(vlax-method-applicable-p currMenuGroup 'Save ) (vlax-invoke-method currMenuGroup 'Save acMenuFileCompiled) (prompt (Strcat "\n" StrItem " item added to contextual menu")) ) (prompt (Strcat "\n" StrItem " already exist in contextual menu") ) ) ) (prompt "\nUnable to Find contextual menu") ) )