自动加载文件目录下的lsp、vlx和fas文件
像迷你工具箱一样把 插件放在支持搜索文件, 自动加载目录下的lsp、vlx和fas文件, ;自动加载文件夹中的lsp,fas,vlx文件(defun loadlspfile(Folder_path / nn f1)
(if Folder_path
(vl-catch-all-apply
'(lambda ( / nn f1)
(setq nn
(append
(xingle_GetFile Folder_path "*.lsp")
(xingle_GetFile Folder_path "*.fas")
(xingle_GetFile Folder_path "*.vlx")
)
)
(foreach f1 nn
(vl-catch-all-apply 'load (list (strcat Folder_path "\\" f1)))
)
)
)
)
)
;语法(vl-directory-files)
;功能:列出给定目录中的所有文件
;说明
;1)参数 directory 为字符串,指定要收集文件的目录。若未指定该参数或参数为 nil,那么vl-directory-files 使用当前目录。
;2)参数 pattern 为字符串,包含文件名的 DOS 方式。如果未指定该参数或参数为 nil,vl-directory-files 假定为 "*.*"。
;3)directories 为整数型,指定返回的表中是否包含路径名。可以指定下列值之一:
;-1仅列出目录。
;0 列出文件和目录(缺省值)。
;1 仅列出文件。
;返回值:
;文件和路径列表。若没有符合指定方式的文件,则返回 nil。
;;pattern类型为list
(defun xingle_GetFile (Dire pattern / SubFile)
(setq SubFile (vl-remove-if
(function (lambda (x) (member x '(".." "."))))
(vl-directory-files Dire pattern 1)
)
)
)
;(xingle_GetFile "Z:\\CAD图库" "*.lsp")
(defun load_Folder_app (path)
(if (findfile path)
(progn
(loadlspfile path)
(princ (strcat path "\n中的lsp,FAS,VLX文件已加载完成>>>>>>>>"))
)
(princ (strcat "\n错误!!!\n请检查路径" path "是否正确<<<<<<<<"))
)
(princ)
)
;;
(defun c:tt()(load_Folder_app "Z:\\mini\\Autoload\\liuxin"));;设置快捷命令,手动加载
(C:tt);;这样写,程序加载这个段代码时,自动激活命令
(defun wyl:autoloadlsp( / lst_fnm lst_dir i )
(setq lst_dir (list "D:/_同步文件/CAD程序/lsp/lisp/通用函数/"))
(setq lst_fnm nil)
(foreach x lst_dir
(setq lst_fnm (append
(mapcar
'(lambda (y)
(strcat x y))
(append
(vl-directory-files x "*.lsp" )
(vl-directory-files x "*.vlx" )
(vl-directory-files x "*.fas" )
)
) lst_fnm))
);endforeach
(setq i 0)
(foreach x lst_fnm
(vl-load-all x)
(princ (strcat "\n" x "已加载" ) )
(princ)
);endforeach
)
(wyl:autoloadlsp);自动执行函数
可以同时加载多个目录的三种类型的文件,需要把路径写死到程序里,例如
(setq lst_dir (list "路径1" "路径2"))
路径中的\应该替换成/或者\\,两者等效
其实这个程序的难点是怎么获取当前程序所在的目录,而实现将程序文件放在一个目录自动加载,而不是像现在一样需要把路径写死. (vl-catch-all-apply
'(lambda ( / nn lfile tmp)
(mai_add_path mai_mini_path (list "door" "fonts" "autoload" "autoload_user" "pattern" "otherplus" "1_lsp" "用户设置" "Decoration"))
(setq nn (strcat mai_mini_path "pattern\\"))
(mai_add_path nn (mai_dos_subdir nn nil))
(mai_change_user (car (mai_get_current_user)))
(foreach tmp (list "AUTOLOAD\\" "AUTOLOAD_USER\\") ;自动加载AUTOLOAD目录下的lsp、vlx和fas文件
(setq tmp (strcat mai_mini_path tmp))
(and (vl-file-directory-p tmp)
(setq nn (append (mai_dos_dir tmp "*.lsp")
(mai_dos_dir tmp "*.vlx")
(mai_dos_dir tmp "*.fas")
)
)
(foreach lfile nn (vl-catch-all-apply 'load (list (strcat tmp lfile))))
)
)
(setq nn 0)
; (princ "\naaa")
(foreach tmp (mai_str2lst (strcase (getenv "ACAD")) ";")
(and (setq lfile (findfile (strcat tmp "\\acad.lsp")))
(< nn 3)
(setq nn (1+ nn))
(load lfile)
)
)
; (princ "\nbbb")
;加载路径下其他acad.lsp文件
)
nil
)
; (princ "\nccc")
(if (findfile "acad.mnl") (load "acad.mnl"))
; (princ "\nddd")
(princ)
这个加载不行 我也想知道,谢谢 我自己也写了一个,自动加载本地指定文件夹的程序,然后还支持共享网络更新 本帖最后由 尘缘一生 于 2019-10-22 22:27 编辑
巧了,我今天刚给我得外挂加了这个功能,发上来
;;说明:;自动加载三领外挂采用第三方程序------目录下的 *.lsp *.vlx*.fas
;;sl-path0程序搜索路径
(defun slstartcx (/ list1 list2 list3 cxlist i n)
(setq list1 (vl-directory-files (strcat sl-path0 "\\实用程序") "*.LSP" 1))
(setq list2(vl-directory-files (strcat sl-path0 "\\实用程序") "*.VLX" 1))
(setq list3(vl-directory-files (strcat sl-path0 "\\实用程序") "*.fas" 1))
(if (/= nil (setq cxlist (append list1 list2 list3)))
(progn
(setq i (- (length cxlist) 1) n 0) ;;;;;返回表的元素数
(while (<= n i)
(load (strcat sl-path0 "\\实用程序\\" (nth n cxlist))) ;;;;;;序列程序加载
(setq n (+ n 1))
)
)
)
)
(slstartcx);;;;;加载目录下程序
尘缘一生 发表于 2019-10-22 22:21
巧了,我今天刚给我得外挂加了这个功能,发上来
;;说明:;自动加载三领外挂采用第三方程序------目录下的 ...
*.ARX能加载不? 我在晓东上找到了一个
(defun wh_jz()
(setq i 0)
(setq lj "D:\\SYWHTool\\Sycui\\Autoload_user");;;LSP文件路径
(setq lsp_list (vl-directory-files lj "*.lsp"));;;LSP格式文件
(setq vlx_list (vl-directory-files lj "*.vlx"));;;vlx格式文件
(setq fas_list (vl-directory-files lj "*.fas"));;;vlx格式文件
(setq lit (append lsp_list vlx_list fas_list));;;LSP和vlx表文件合并
(repeat (length lit);;;;循环
(setq lsp (nth i lit))
(setq lsp_lj (strcat lj "\\" lsp))
(load lsp_lj)
(setq i (+ 1 i))
(prompt (strcat "\n" lsp_lj))
)
(prompt (strcat "\n共加载程序" (rtos i 2 0) "个"))
)
(wh_jz)
尘缘一生 发表于 2019-10-22 22:21
巧了,我今天刚给我得外挂加了这个功能,发上来
;;说明:;自动加载三领外挂采用第三方程序------目录下的 ...
谢谢,{:1_1:},{:1_1:},{:1_1:}
页:
[1]
2