lisp添加文件夹到"支持文件搜索路径"
;;; 设置路径===xyp1964<br/>(defun c:test041 (/ a pa lst ls1 path)<br/> (setq a (getenv "ACAD")<br/> pa (getstring "\n盘符 : ") ; 要增加的路径,由用户自己改写<br/> lst (list ":\block\a1" ":\block\a2" ":\block\a3" ":\bk\b1" ":\bk\b2" ":\bk\b3" ":\bk\pat" ;<br/> )<br/> ls1 (car lst)<br/> path (strcat ";" pa ls1)<br/> lst (vl-remove ls1 lst)<br/> )<br/> (while lst<br/> (setq ls1 (car lst)<br/> path (strcat path (strcat ";" pa ls1))<br/> lst (vl-remove ls1 lst)<br/> )<br/> )<br/> (setenv "ACAD" (strcat a path))<br/> (getenv "ACAD")<br/>)<br/>;;; yfy2003<br/>;;; 添加文件夹到"支持文件搜索路径"中的指定位置<br/>(defun addSupportPath (dir pos / tmp c)<br/> (setq tmp ""<br/> c -1<br/> )<br/> (if (not pos)<br/> (setq tmp (strcat (getenv "ACAD") ";" dir))<br/> (mapcar<br/> '(lambda (x)<br/> (setq tmp (if (= (setq c (1+ c))<br/> pos<br/> )<br/> (strcat tmp ";" dir ";" x)<br/> (strcat tmp ";" x)<br/> )<br/> )<br/> )<br/> (parse (getenv "ACAD") ";")<br/> )<br/> )<br/> (setenv "ACAD" tmp)<br/> (princ)<br/>)<br/>;| 调用示例 (addSupportPath "D:\\myFolder" 2)<br/>参数文件夹路径及插入的位置( "ACAD"<--- 一定要大写)<br/>注意:位置参数为空时将文件夹添加到路径最后。<br/>位置参数为0时将文件夹添加到路径最前端。 |;<br/>(defun Example_SupportPath () ; 这个范例返回<br/> ; SupportPath的当前设定值,接着改变它的值,最后恢复初始值<br/> (VL-LOAD-COM)<br/> (setq AcadObject (vlax-get-acad-object)<br/> AcadDocument (vla-get-ActiveDocument AcadObject)<br/> mSpace (vla-get-ModelSpace AcadDocument)<br/> )<br/> (setq preferenceSel (vla-get-Preferences AcadObject))<br/> (setq fileSel (vla-get-Files preferenceSel)) ; 取出当前的SupportPath值<br/> (setq currSupportPath (vla-get-SupportPath fileSel))<br/> (princ "SupportPath的值当前设定为: ")<br/> (princ currSupportPath)<br/> (princ " SupportPath范例\\n")<br/> (PROMPT "<Enter>进行:")<br/> (VL-CMDF pause) ; 改变SupportPath的值<br/> (vla-put-SupportPath fileSel "TestSupportPath")<br/> (setq newSupportPath (vla-get-SupportPath fileSel))<br/> (princ "SupportPath的新值设定为: ")<br/> (princ newSupportPath)<br/> (princ " SupportPath范例\\n")<br/> (PROMPT "<Enter>进行:")<br/> (VL-CMDF pause) ; 将 SupportPath 重设为原来的值<br/> (vla-put-SupportPath fileSel currSupportPath)<br/> (vla-Regen AcadDocument acAllViewports)<br/> (princ "SupportPath的值已经重设为: ")<br/> (princ currSupportPath)<br/> (princ " SupportPath范例\\n")<br/> (princ)<br/>)<br/><br/> 另外补充一个错误,是“\\”不是“\”,不过还是非常谢谢你分享的源码。 这个代表不错,谢谢 我发现这几个程序中前2个都有错误,分号放错地方了,而且第一个那样写程序应该比较浪费,实际可以写的更省略一些的。 非常好的帖子,学习了。 萌新表示值得研究 ; 添加文件夹到"支持文件搜索路径"中的指定位置 (parse (getenv "ACAD") ";") 不能执行 是什么原因 好东西,谢谢 没有 parse 子命令
页:
[1]