onej
发表于 2005-4-22 21:31:00
谢谢秋枫,可编译错误啊,
didini
发表于 2005-4-22 21:42:00
(while (<FONT color=#ff0000><B>&gt</B></FONT> “这个到底是什么啊?”StringLen 0)<BR> (setq n 1)<BR> (setq char (substr SearchStr 1 1))<BR> (while (and (/= char Delimiter) (/= char ""))<BR> (setq n (1+ n))<BR>
秋枫
发表于 2005-4-23 09:41:00
onej发表于2005-4-22 21:31:00static/image/common/back.gif谢谢秋枫,可编译错误啊,17969
<BR>笔误,不好意思。把var行去掉即可。
var行用于定义内部变量,这个函数没有内部变量,所以多余,去掉即可。
秋枫
发表于 2005-4-23 09:42:00
didini发表于2005-4-22 21:42:00static/image/common/back.gif(while (&gt “这个到底是什么啊?”StringLen 0) (setq n 1) (setq char (substr SearchStr 1 1)) ...
<BR>是明经通道论坛自动转化了大于符号(尖括号)。现已修正。请重新拷贝。
wengsg
发表于 2005-4-23 10:40:00
还是没用!
程序如下:
;;; 判断是否加载本文件<BR>(if (car (atoms-family 1 '("vl-load-com")))<BR> (vl-load-com)<BR> ;;else<BR> (progn<BR> (Alert<BR> "这个程序集是为AutoCAD 2000以及更高的版本设计的,许多程序有可能在没有Visual Lisp for R14支持的AutoCAD R14上不能正确地运行。"<BR> )<BR> (exit) ; 版本不符,退出加载。<BR> )<BR>)<BR>;;; 以下定义文件中用到的函数<BR>;;;----------------------------------------------------------------------------------
;;; 取得本程序的路径<BR>;;; ---------------------------------------------------------------------------------<BR>(defun GetMyApplicationPath (AppID)<BR> (vl-registry-read<BR> (strcat<BR> "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"<BR> AppID<BR> "_is1"<BR> )<BR> "Inno Setup: App Path"<BR> )<BR>)
(defun GetWLTOOLPath ()<BR> (GetMyApplicationPath "WLTOOL for AutoCAD")<BR>)
;;; 解析字符串为表(函数来自明经通道转载)<BR>;;; ---------------------------------------------------------------------------------<BR>(defun strParse (Str Delimiter / SearchStr StringLen return n char)<BR> (setq SearchStr Str)<BR> (setq StringLen (strlen SearchStr))<BR> (setq return '())<BR> (while (> StringLen 0)<BR> (setq n 1)<BR> (setq char (substr SearchStr 1 1))<BR> (while (and (/= char Delimiter) (/= char ""))<BR> (setq n (1+ n))<BR> (setq char (substr SearchStr n 1))<BR> ) ;_ end of while<BR> (setq return (cons (substr SearchStr 1 (1- n)) return))<BR> (setq SearchStr (substr SearchStr (1+ n) StringLen))<BR> (setq StringLen (strlen SearchStr))<BR> ) ;_ end of while<BR> (reverse return)<BR>) ;_ end of defun
;;; 反解析表为字符串(函数来自明经通道转载)<BR>;;; ---------------------------------------------------------------------------------<BR>(defun StrUnParse (Lst Delimiter / return)<BR> (setq return "")<BR> (foreach str Lst<BR> (setq return (strcat return Delimiter str))<BR> ) ;_ end of foreach<BR> (substr return 2)<BR>) ;_ end of defun
;;; 移除支持文件搜索路径<BR>;;; ---------------------------------------------------------------------------------<BR>(defun QF_RemoveSupportPath (PathToRemove / supportlist)<BR> (setq supportlist (strparse (getenv "ACAD") ";"))<BR> (setq supportlist (vl-remove "" supportlist))<BR> (setq supportlist<BR> (vl-remove-if<BR> '(lambda (x) (= (strcase x) (strcase PathToRemove)))<BR> supportlist<BR> )<BR> )<BR> (setenv "ACAD" (strUnParse supportlist ";"))<BR>)
;;; 添加支持文件搜索路径<BR>;;; ---------------------------------------------------------------------------------<BR>;;; note: 第二个参数如果为真, 插最前,否则插最后<BR>;;; <BR>(defun QF_AddSupportPath (PathToAdd isFirst / supportlist)<BR> (QF_RemoveSupportPath PathToAdd)<BR> (setq supportlist (strparse (getenv "ACAD") ";"))<BR> (setq supportlist (vl-remove "" supportlist))<BR> (if isFirst<BR> (setq supportlist (cons PathToAdd supportlist))<BR> (setq supportlist (append supportlist (list PathToAdd)))<BR> )<BR> (setenv "ACAD" (strUnParse supportlist ";"))<BR>)<BR>(defun Load_WLTOOLMenu (/ acadver)<BR> (setq acadver (atof (getvar "acadver")))<BR> (cond<BR> ((and (>= acadver 15.0) (< acadver 16.0))<BR> (command "_menuload" "WLTOOL.mnu")<BR> )<BR> ((and (>= acadver 16.0) (<= acadver 16.1))<BR> (command "_menuload" "WLTOOL2004.mnu")<BR> )<BR> ((>= acadver 16.2) (command "_menuload" "WLTOOL2006.mnu"))<BR> )<BR>)
;;; The following code "placemenu" written by LUCAS<BR>;;; 插入菜单条 Placemenu由LUCAS编写<BR>;;; ---------------------------------------------------------------------------------<BR>(defun WLTOOL_PlaceMenu (/ n)<BR> (if (menugroup "WLTOOL")<BR> (progn<BR> (setq n 1)<BR> (while (< n 24)<BR> (if (menucmd (strcat "P" (itoa n) ".1=?"))<BR> (setq n (+ n 1))<BR> (progn<BR> (if (> n 3)<BR> (setq n (- n 2))<BR> (setq n 3)<BR> ) ;if
(menucmd (strcat "p" (itoa n) "=+WLTOOL.pop1"))<BR> (setq n 25)<BR> ) ;progn<BR> ) ;if<BR> ) ;while<BR> ) ;progn<BR> ) ;if<BR> (princ)<BR>)
;;好了,下面可以开始设计初始化工具箱的主程序了:
<BR>;;; 初始化主函数<BR>;;; ---------------------------------------------------<BR>(defun Init_WLTOOL ()<BR> ;; 添加支持路径<BR> (QF_AddSupportPath (GetWLTOOLPath) nil)<BR> (QF_AddSupportPath (strcat (GetWLTOOLPath) "<A href="file://DOOR/" target="_blank" >\\DOOR</A>") nil)<BR> (QF_AddSupportPath (strcat (GetWLTOOLPath) "<A href="file://FONTS/" target="_blank" >\\FONTS</A>") nil)<BR> (QF_AddSupportPath (strcat (GetWLTOOLPath) "<A href="file://LINE/" target="_blank" >\\LINE</A>") nil)<BR> (QF_AddSupportPath (strcat (GetWLTOOLPath) "<A href="file://LISP/" target="_blank" >\\LISP</A>") nil)<BR> (QF_AddSupportPath (strcat (GetWLTOOLPath) "<A href="file://PAT/" target="_blank" >\\PAT</A>") nil)<BR> (QF_AddSupportPath (strcat (GetWLTOOLPath) "<A href="file://SLB/" target="_blank" >\\SLB</A>") nil)<BR> ;; 如果菜单组还没有被加载,则加载之<BR> (if (not (menugroup "WLTOOL"))<BR> (Load_WLTOOLMenu)<BR> )
;; 安排菜单条的位置<BR> (WLTOOL_PlaceMenu)
(princ)<BR>)<BR>;;; 以上函数部分定义完毕
<BR>;;主程序定义完毕,可以逐条执行了:
<BR>;;; -----------------------------------------------------<BR>;;; 主程序:<BR>;;; -----------------------------------------------------<BR>(princ "\n加载WLTOOL工具集……")
(setq WLTOOL_cmdecho_save (getvar "cmdecho"))<BR>(setvar "cmdecho" 0)
(Init_WLTOOL)
<BR>(setvar "cmdecho" WLTOOL_cmdecho_save)<BR>(setq WLTOOL_cmdecho_save nil)
(princ "\nWLTOOL工具集加载完毕。版本 2005.4")<BR>(princ)
;; autoload<BR>(autoload "CWCT" '("CHANGE-THICKNESS" "CHANGE-WIDTH"))<BR>;; ……下略
<BR>
秋枫
发表于 2005-4-23 11:17:00
朋友,你这个是纯LISP问题啊,你可以用VLISP设断点调试看看什么地方错了呀。
我猜一下:
(defun GetWLTOOLPath ()<BR> (GetMyApplicationPath "WLTOOL for AutoCAD")<BR>)
这个的返回值对不对?“WLTOOL for AutoCAD”是不是与安装向导中的设置一致?
wengsg
发表于 2005-4-23 11:45:00
是这个"这个的返回值对不对?“WLTOOL for AutoCAD”是不是与安装向导中的设置一致?"原因.谢谢!
但我的菜单还是无法自动加载.
wengsg
发表于 2005-4-23 16:35:00
谢谢楼主,我的问题已解决!
didini
发表于 2005-4-23 20:43:00
经过一天的努力终于解决了!
但是有个问题,在制作setup文件的时候,需要制作一个自动加载的lisp文件,或者其它的文件,在这个文件中实现添加支持路径和菜单文件,当安装上setup以后,第一次打开cad,就会发现,在新添加路径中的acaddoc.lsp,并没有加载,但在以后就不会出现这样的情况了!
这种情况能避免吗?
秋枫
发表于 2005-4-23 23:47:00
既然提供了自动加载文件,就没有必要使用acaddoc.lsp. 因为这个自动加载文件每次都会加载的。
因为这个文件很可能在其它支持路径中也有。有可能是用户自己写的,这样会导致冲突。
这种情况无法避免。你如果要加载的话,你可以在你的LSP中添加支持路径后,自己在LISP程序中加载,
例:
(addsupportpath "..XXXX")
(if (findfile "acaddoc.lsp") (load "acaddoc.lsp"))
(add supportpath ".....")
...