:)
谢谢秋枫版主提供代码。
版主的代码应该考虑的因素比较多的了。
为了好好学习,也在网上找了一下资料,好像大概都是两种写法,setenv和vla-put-supportpath
学习作笔记~
[AcadX.com]的代码,可能年代也挺久的,和秋枫版主的类似
- (defun addSP (dir pos / tmp c lst)
- (setq tmp ""
- c -1
- )
- (if (not (member (strcase dir) (setq lst (mapcar
- 'strcase
- (parse (getenv "ACAD") ";")
- )
- )
- )
- )
- (progn
- (if (not pos)
- (setq tmp (strcat (getenv "ACAD") ";" dir))
- (mapcar
- '(lambda (x)
- (setq tmp (if (= (setq c (1+ c))
- pos
- )
- (strcat tmp ";" dir ";" x)
- (strcat tmp ";" x)
- )
- )
- )
- lst
- )
- )
- (setenv "ACAD" tmp)
- )
- )
- (princ)
- )
- (defun parse (str delim / lst pos)
- (setq pos (vl-string-search delim str))
- (while pos
- (setq lst (cons (substr str 1 pos) lst)
- str (substr str (+ pos 2))
- pos (vl-string-search delim str)
- )
- )
- (if (> (strlen str) 0)
- (setq lst (cons str lst))
- )
- (reverse lst)
- )
- ; Arguments : A folder path and the position at which to insert it. (0 based.)
- ; Here's an example to add a support folder :
- (addSP "c:\\afralisp" 3)
John Laidler ,也用setenv函数,没有选择位置项
- ;;; John Laidler
- ;;; [url]http://groups.google.com/group/autodesk.autocad.customization/browse_thread/thread/d1072d257e2d2174/4[/url]
- b0851cbad83d142?lnk=gst&q=add+support+path&rnum=4#4b0851cbad83d142
- (defun CS:AddSupportPath (dir / tmp Cpath)
- (vl-load-com)
- (setq Cpath (getenv "ACAD")
- tmp (strcat ";" dir ";")
- )
- (if (not (vl-string-search dir cpath))
- (setenv "ACAD" (strcat Cpath ";" dir))
- )
- (princ)
- )
- (CS:ADDSUPPORTPATH "c:\\b")
下面三个是theswamp找到的函数
MP,只用一句话,是vla函数
- ;;;[MP]
- (defun _AddSupportPath ( path / files )
- (vla-put-supportpath
- (setq files
- (vla-get-files
- (vla-get-preferences
- (vlax-get-acad-object)
- )
- )
- )
- (strcat
- (vla-get-supportpath files) ";"
- path
- )
- )
- )
- (_addsupportpath "c:\\3")
Jeff_M和kerry Brown都是为了一个问题写的,希望一次加多个子目录
- (defun c:ldp (/ FilePrefs addEnviron EnvironBase acadEnviron)
- (setq FilePrefs (vla-get-files (vla-get-preferences
- (vlax-get-acad-object)
- )
- )
- )
- (setq acadEnviron (vla-get-supportpath FilePrefs))
- (setq EnvironBase "M:\\_Cad Support\\AutoCAD 2004\\2004dannyCAD\\MENU\")
- (setq addEnviron '("Area" "Blocks"
- "Dimensions" "Layers"
- "Linetypes" "Plotting"
- "Settings" "Shortcuts"
- "Text"
- );;;add any others you want to this list
- )
- (if (not (vl-string-search (strcat EnvironBase (car addEnviron))
- acadEnviron
- );;;make sure we haven't already done this
- )
- (progn
- (mapcar
- '(lambda (x)
- (setq acadEnviron (strcat acadEnviron ";" EnvironBase x))
- )
- addEnviron
- )
- (vla-put-supportpath FilePrefs acadEnviron)
- (princ "\n....Support Paths updated!")
- );progn
- (princ "\n....Support Paths were previously updated...nothing done.")
- );if
- (princ)
- )
-
Kerry Brown
- (VL-LOAD-COM)
- (prompt "\n < LDP > Load Dependant Support Paths to profile [V0.01]")
- (defun c:LDP (/ fileprefs addenviron environbase acadenviron)
- (setq fileprefs (vla-get-files (vla-get-preferences
- (vlax-get-acad-object)
- )
- )
- )
- (setq acadenviron (vla-get-supportpath fileprefs))
- (setq environbase "M:\\_Cad Support\\AutoCAD 2004\\2004dannyCAD\\MENU\")
- (setq addenviron '("Area" "Blocks"
- "Dimensions" "Layers"
- "Linetypes" "Plotting"
- "Settings" "Shortcuts"
- "Text"
- )
- )
- (mapcar
- '(lambda (x)
- (setq acadenviron (strcat acadenviron ";" environbase x))
- )
- addenviron
- )
- (vla-put-supportpath fileprefs acadenviron)
- (PRINC)
- )
|