楼主的菜单做的不错,借楼主的插件做了个[信·CAD]工具箱的适配,可以自动生成工具箱的相应菜单
附上适配源码- (defun mMenu:subMenu (subList mMenu bSpace
- /
- subMenu
- )
- (setq subList (cdr (assoc "SUBLIST" subList)))
- (while subList
- (setq subMenu (car subList)
- subList (cdr subList)
- )
- (cond
- ;菜单
- ((= (cdr (assoc "TYPE" subMenu)) "MENU")
- (progn
- (if (not bSpace) (progn (write-line "\t[--]" mMenu) (setq bSpace T)))
- (mMenu:subMenu subMenu mMenu bSpace)
- )
- )
- ;命令
- ((= (cdr (assoc "TYPE" subMenu)) "COMMAND")
- (progn
- (write-line (strcat "\t[" (cdr (assoc "NAME" subMenu)) "]"
- "^C^C"
- (apply '7Xin:CMDKernelName (cdr (assoc "COMMAND" subMenu)))
- )
- mMenu)
- (setq bSpace nil)
- )
- )
- ((= (cdr (assoc "TYPE" subMenu)) "SPACER")
- (if (not bSpace) (progn (write-line "\t[--]" mMenu) (setq bSpace T)))
- )
- )
- )
- )
- (defun mMenu:MainMenu ( /
- mMenu
- lstMenu
- subMenu
- cmd
- )
- (if (setq mMenu (findfile "mMenu.Mnu"))
- (progn
- (setq mMenu (open mMenu "w"))
- (write-line "***menugroup=信·CAD" mMenu)
- (setq lstMenu (cdr (assoc "SUBLIST" 7Xin::MenuList)))
- (while lstMenu
- (setq subMenu (car lstMenu)
- lstMenu (cdr lstMenu)
- )
- (cond
- ;子菜单
- ((= (cdr (assoc "TYPE" subMenu)) "MENU")
- (progn
- (write-line "***POP1" mMenu)
- (write-line (strcat "[" (cdr (assoc "NAME" subMenu)) "]") mMenu)
- (mMenu:subMenu subMenu mMenu nil)
- (write-line "" mMenu)
- )
- )
- ;根菜单命令
- ((= (cdr (assoc "TYPE" subMenu)) "COMMAND")
- (progn
- (write-line "***POP1" mMenu)
- ;(write-line (strcat "[" (cdr (assoc "NAME" subMenu)) "]") mMenu)
- (write-line (strcat "[" (cdr (assoc "NAME" subMenu)) "]"
- "^C^C"
- (apply '7Xin:CMDKernelName (cdr (assoc "COMMAND" subMenu)))
- )
- mMenu)
- )
- (write-line "" mMenu)
- )
- ((= (cdr (assoc "TYPE" subMenu)) "SPACER")
- )
- )
- )
- (write-line "***POP1" mMenu)
- (write-line "[更新CAD菜单]^C^CEF_MAKECADMENU" mMenu)
- (write-line "***POP500" mMenu)
- (close mMenu)
- )
- )
- )
- ;生成CAD菜单
- (defun C:EF_MakeCADMenu ()
- (mMenu:MainMenu) ;生成菜单
- ;尝试卸载插件
- (vl-catch-all-apply 'arxunload (list "MMenu.arx"))
- (vl-catch-all-apply 'arxunload (list "MMenu_x64.arx"))
- (setq 7Xin::Loaded (vl-remove "[CAD]CAD菜单" 7Xin::Loaded))
- (7Xin:LoadPlugin "[CAD]CAD菜单")
- )
|