乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: MarcoW

[编程交流] 如何加载/卸载菜单'

[复制链接]

59

主题

327

帖子

268

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
295
发表于 2022-7-6 15:10:46 | 显示全部楼层
LISP例程将仅返回T或显示警报。
 
我真的需要阅读整条线索,但你是否“顺其自然”完全取决于你自己
回复

使用道具 举报

1

主题

316

帖子

311

银币

初来乍到

Rank: 1

铜币
29
发表于 2022-7-6 15:12:03 | 显示全部楼层
回复

使用道具 举报

59

主题

327

帖子

268

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
295
发表于 2022-7-6 15:14:59 | 显示全部楼层
Okay, that was a little stupid I guess... but still dont work.
 
The lisp:
 

[code](defun c:loadit (/ cui_database mnbar flag)(vl-load-com)(setq cui_database(list"options" ;
回复

使用道具 举报

1

主题

316

帖子

311

银币

初来乍到

Rank: 1

铜币
29
发表于 2022-7-6 15:18:28 | 显示全部楼层
works fine here, try restarting acad, if still not ok, may be others can assist.
回复

使用道具 举报

24

主题

1265

帖子

1028

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
362
发表于 2022-7-6 15:23:10 | 显示全部楼层
See also this example:
http://www.theswamp.org/index.php?topic=7731.msg98122#msg98122
回复

使用道具 举报

59

主题

327

帖子

268

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
295
发表于 2022-7-6 15:24:25 | 显示全部楼层
I have Autocad 2007, maybe that is important to know...
 
The code:
  1. ;; -- Function MeLoadPartMenu; Loading partial menus.; Arguments [Type]:;Grp = Menu group [sTR]                     [b]SO Grp = options (?)[/b];Nme = Menu file name (w/o .ext) [sTR] [b]SO Nme = options.mnu (?)[/b]; Return [Type]:;   > True if file found [bOOLEAN];   > Nil if not [bOOLEAN]; Notes:;   - Already loaded menu remains;   - Consider changed menu file paths;(defun MeLoadPartMenu ([b]options[/b] options.mnu / AcaObj FilPth GrpCol MnuExt MnuLst)(setq AcaObj (vlax-get-acad-object)      GrpCol (vla-get-MenuGroups AcaObj)      MnuExt (< (atof (getvar "ACADVER")) 16.2) ".mnc" ".cui"))(vlax-for Obj GrpCol (setq FilPth (strcase (vla-get-MenuFileName Obj))       MnuLst (cons                                           (strcat                (vl-filename-directory FilPth)                "\" (vl-filename-base FilPth)               )               MnuLst              ) ) (vlax-release-object Obj))(if (or     (setq FilPth (findfile (strcat Nme MnuExt)))     (setq FilPth (findfile (strcat Nme ".mnu")))    ) (progn  (setq FilPth (strcat                (vl-filename-directory FilPth)                "\" (vl-filename-base FilPth)               )  )  (if (menugroup Grp)   (if (not (member (strcase FilPth) MnuLst))    (progn     (MeUnloadMenuGroup Grp)     (vla-load (vla-get-MenuGroups AcaObj) Nme)    )   )   (vla-load GrpCol Nme)  )  T ) (alert  (strcat   "Menu file '" Nme MnuExt "/.mnu' not found."   "\nCheck your installation please."  ) )));; -- Function MeUnloadPartMenu; Unload a partial menu.; Arguments [Type]:;   Grp = Menu group name [sTR]; Return [Type]:;   > Null; Notes:;   None;(defun MeUnloadPartMenu (Grp)(vlax-for Obj (vla-get-MenuGroups (vlax-get-acad-object)) (if (eq (vla-get-Name Obj) Grp)  (vla-unload Obj) ) (vlax-release-object Obj))(princ))
 
How do I run this? I know how to get lisp running, this isn't lisp  ?
And when my menu is called options is it correct as altered above?
Pff... I shall win !!
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:27:55 | 显示全部楼层
This is LISP, but they are sub-functions, hence will need to be called from a main-function with arguments
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:32:14 | 显示全部楼层
I think the LISP has been tampered with, some parts of it were wrong/missing:
 
  1. ; ; -- Function MeLoadPartMenu ; Loading partial menus. ; Arguments [Type]: ;Grp = Menu group [sTR] SO Grp = options (?) ;Nme = Menu file name ([color=Red][b]w/o .ext[/b][/color]) [sTR] SO Nme = options.mnu (?) ; Return [Type]: ; > True if file found [bOOLEAN] ; > Nil if not [bOOLEAN] ; Notes: ; - Already loaded menu remains ; - Consider changed menu file paths ;(defun MeLoadPartMenu  ([b][color=Red]Grp Nme[/color][/b] / AcaObj FilPth GrpCol MnuExt MnuLst) (setq AcaObj (vlax-get-acad-object)       GrpCol (vla-get-MenuGroups AcaObj)       MnuExt [b][color=Red](if[/color][/b] (< (atof (getvar "ACADVER")) 16.2) ".mn[b][color=Red]u[/color][/b]" ".cui")) (vlax-for Obj  GrpCol   (setq FilPth (strcase (vla-get-MenuFileName Obj))         MnuLst (cons                  (strcat                    (vl-filename-directory FilPth)                    "\"                    (vl-filename-base FilPth)                    )                  MnuLst                  )         )   (vlax-release-object Obj)   ) (if (or       (setq FilPth (findfile (strcat Nme MnuExt)))       (setq FilPth (findfile (strcat Nme ".mnu")))       )   (progn     (setq FilPth (strcat                    (vl-filename-directory FilPth)                    "\"                    (vl-filename-base FilPth)                    )           )     (if (menugroup Grp)       (if (not (member (strcase FilPth) MnuLst))         (progn           (MeUnloadMenuGroup Grp)           (vla-load (vla-get-MenuGroups AcaObj) Nme)           )         )       (vla-load GrpCol Nme)       )     T     )   (alert     (strcat       "Menu file '" Nme MnuExt "/.mnu' not found." "\nCheck your installation please.")     )   ) ) ; ; -- Function MeUnloadPartMenu ; Unload a partial menu. ; Arguments [Type]: ; Grp = Menu group name [sTR] ; Return [Type]: ; > Null ; Notes: ; None ;(defun MeUnloadPartMenu  (Grp) (vlax-for Obj  (vla-get-MenuGroups (vlax-get-acad-object))   (if (eq (vla-get-Name Obj) Grp)     (vla-unload Obj)     )   (vlax-release-object Obj)   ) (princ) )[b][color=Red](defun c:test () (MeLoadPartMenu "options" "options") (princ))[/color][/b]
 
 
This is what I think on first glance, but haven't had time to look properly tbh.
回复

使用道具 举报

59

主题

327

帖子

268

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
295
发表于 2022-7-6 15:35:40 | 显示全部楼层
Hi Lee Mac, thank you for your help.
Yes the lisp runs now, but the problem still is not solved.
Aargh...
 
Commandline: menuload [enter]
Commandline: browse [enter]
Browsing to the desired .mnu file [open]
Then the browsed file is loaded by pressing the button "load".
This way it is visible, not via the lisproutine allthough it is loaded.
 
Beats me.
 
Should I consider "leave it be" ?
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:37:58 | 显示全部楼层
The LISP routine will only return T or the alert will show.
 
I need to read the whole thread really - but whether you "leave it be" is entirely up to you
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-5 00:33 , Processed in 0.779581 second(s), 70 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表