Dear sir,
see this code i think use full for create u r task
- ;;;-===-==-==-==-=-==-==-==-=-==-==-=-==-==-=-==-==-=-==-==-=-==-=-==-
- ;;; (crpd:loadDynamicPopUpMenu '("Mymenu"(("Do Command1" . "command1")("Do Command2" . "command2"))))
- ;;;-===-==-==-==-=-==-==-==-=-==-==-=-==-==-=-==-==-=-==-==-=-==-=-==-
- (defun crpd: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)
- )
- "ACAD"
- )
- cmd (lambda (x)
- (strcat "\033\033\137" x "\040")
- )
- )
- (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)
- (cmd (cdr e))
- )
- )
- (vla-insertinmenubar
- newmenu
- (1+ (vla-get-count
- (vla-get-menubar acadapp)
- )
- )
- )
- )
- (princ (strcat "\nerror of type ohno "
- (car menulist)
- " menu is already loaded "
- )
- )
- )
- )
- )
- (princ)
- )
|