OPENDCL停靠式工具条与批处理脚本冲突
OPENDCL停靠式工具条启动CAD时自动加载后,执行批处理的脚本时报错,弹出以下错误信息,但把这个停靠式工具条关闭并不启动CAD时自动加载就不出错,谁知道这是什么问题啊这段代码应该没什么问题,应该是OPENDCL对话框的与批处理的脚本之间有什么冲突,执行的代码如下:
(defun c:test(/ FILE_LIST FOLD SF SFF RunNow)
(vl-load-com)
(defun GetFileList(dirName / files lst)
(defun path-addBackSlash(path)
(if (not (member (substr path (strlen path)) '("\\" "/")))
(strcat path "\\")
path))
(setq dirName (path-addBackSlash dirName)
files (mapcar '(lambda (x) (strcat dirName x))
(vl-directory-files dirName "*.dwg" 1)))
(mapcar '(lambda (x) (setq lst (append lst (GetFileList (strcat dirName x)))))
(vl-remove-if '(lambda (x) (member x '("." "..")))
(vl-directory-files dirName nil -1)))
(append files lst))
;; 用法:(qf_getFolder msg)
;; 例子:(qf_getFolder "选择文件夹:")
;; 返回值:字符串,文件夹路径,如果点了cancel, 返回nil
(defun qf_getFolder(msg / WinShell shFolder path catchit)
(vl-load-com)
(setq winshell (vlax-create-object "Shell.Application"))
(setq shFolder (vlax-invoke-method WinShell 'BrowseForFolder 0 msg 1))
(setq catchit
(vl-catch-all-apply '(lambda ()
(setq shFolder (vlax-get-property shFolder 'self))
(setq path (vlax-get-property shFolder 'path)))))
(if (vl-catch-all-error-p catchit)
nil
path))
(setq fold (qf_getFolder "选择文件所在目录:"))
(if fold
(progn
(setq file_list (GetFileList fold))
(if file_list
(progn
(setq sf (strcat (getvar "TEMPPREFIX") "批处理文件20100806.scr"))
(setq sff (open sf "w"))
(mapcar
'(lambda (x)
(princ (strcat
"open \"" x "\"\n"
"-purge all * n zoom e qsave close\n")
sff)
;;;;;加了清理
)
file_list)
(close sff)
(princ
(strcat "\n目录下" fold "\n\t共有DWG文件数: " (itoa (length file_list))))
(initget "Y N")
(setq RunNow (getkword "\n是否立刻执行[是(Y)/否(N)]:<否>"))
(if (= RunNow "Y")
(progn (command "._script" sf) (princ "\n处理完成"))
(princ "\n放弃立刻执行")))
(princ "\n目录下没有DWG文件")))
(princ "\n请选择目录"))
(princ)) 现在只能时用VB写段程序,依次打开CAD图形文件,打开后再执行LISP程序,执行完后再用VB关闭图形才可以。 引发事件设置成1吧! 学习学习下看看
页:
[1]