Add & Remove Support File Search Paths
The following functions enable a user to modify the list of Support File Search Paths (SFSP) recognised by the AutoCAD application.
These paths may be found & altered manually from within the Files tab of the Options menu; or programmatically, by either querying & modifying the value of the Visual LISP ActiveX SupportPath property of the Files Object (derived from the Preferences Object, which is itself derived from the Application object); or by altering the value held by the ACAD environment variable.
Contents
Add Support File Search Paths
Function Syntax | (LM:sfsp+ <lst>) |
Current Version | 1.4 |
Donate |
Arguments | ||
---|---|---|
Symbol | Type | Description |
lst | List | List of paths to add |
Returns | ||
Type | Description | |
String | Value of ACAD environment variable following modification |
Function Description
This function will modify the semi-colon delimited string value of the ACAD environment variable to incorporate all valid paths in a given list which do not already appear in the list of support paths stored by the string.
;; Add Support File Search Paths - Lee Mac ;; Adds a list of Support File Search Paths, excluding duplicates and invalid paths. ;; lst - [lst] list of paths to add, e.g. '("C:\\Folder1" "C:\\Folder2" ... ) ;; Returns: [str] "ACAD" Environment String following modification (defun LM:sfsp+ ( lst ) ( (lambda ( str lst ) (if (setq lst (vl-remove-if '(lambda ( x ) (or (vl-string-search (strcase x) (strcase str)) (not (findfile x)) ) ) lst ) ) (setenv "ACAD" (strcat str ";" (apply 'strcat (mapcar '(lambda ( x ) (strcat x ";")) lst)))) ) ) (vl-string-right-trim ";" (getenv "ACAD")) (mapcar '(lambda ( x ) (vl-string-right-trim "\\" (vl-string-translate "/" "\\" x))) lst) ) )
Example Function Call
(LM:sfsp+ '("C:\\Folder1" "C:\\Folder2" "C:\\Folder3"))
Add Support File Search Paths at n
Function Syntax | (LM:sfsp+n <lst> [idx]) |
Current Version | 1.4 |
Donate |
Arguments | ||
---|---|---|
Symbol | Type | Description |
lst | List | List of paths to add |
idx | Integer | [Optional] Zero-based index at which to add new paths |
Returns | ||
Type | Description | |
String | Value of ACAD environment variable following modification, else nil if unchanged. |
Function Description
This function will modify the semi-colon delimited string value of the ACAD environment variable to incorporate all valid paths in a given list which do not already appear in the list of support paths stored by the string.
The list of paths will be inserted at the position given by a supplied zero-based index parameter; for example, if the supplied index is zero, the paths will appear first in the list of AutoCAD Support File Search Paths and will hence be searched first when these paths are queried.
The index parameter is optional: if this parameter is nil, the set of paths will be added to the front of the list; if this parameter exceeds the highest index, the paths will be appended to the end of the list.
;; Add Support File Search Paths at 'n' - Lee Mac ;; Adds a list of Support File Search Paths, excluding duplicates and invalid paths. ;; lst - [lst] list of paths to add, e.g. '("C:\\Folder1" "C:\\Folder2" ... ) ;; idx - [int] [optional] zero-based index at which to add new paths ;; Returns: [str] "ACAD" Environment String following modification (defun LM:sfsp+n ( lst idx / add ) (defun add ( str new idx / pos ) (if (< 0 idx) (if (setq pos (vl-string-position 59 str)) (strcat (substr str 1 (1+ pos)) (add (substr str (+ pos 2)) new (1- idx))) (strcat ";" new) ) (strcat new str ";") ) ) ( (lambda ( str lst ) (if (setq lst (vl-remove-if '(lambda ( x ) (or (vl-string-search (strcase x) (strcase str)) (not (findfile x)) ) ) lst ) ) (setenv "ACAD" (add str (apply 'strcat (mapcar '(lambda ( x ) (strcat x ";")) lst)) idx)) ) ) (vl-string-right-trim ";" (getenv "ACAD")) (mapcar '(lambda ( x ) (vl-string-right-trim "\\" (vl-string-translate "/" "\\" x))) lst) ) )
Example Function Call
(LM:sfsp+n '("C:\\Folder1" "C:\\Folder2" "C:\\Folder3") 0)
Remove Support File Search Paths
Function Syntax | (LM:sfsp- <lst>) |
Current Version | 1.4 |
Donate |
Arguments | ||
---|---|---|
Symbol | Type | Description |
lst | List | List of paths to remove |
Returns | ||
Type | Description | |
String | Value of ACAD environment variable following modification, else nil if unchanged. |
Function Description
This function will modify the semi-colon delimited string value of the ACAD environment variable to remove all paths in a given list which are found to appear in the list of support paths stored by the string.
The list of paths supplied to the function is case-insensitive.
;; Remove Support File Search Paths - Lee Mac ;; Removes a list of Support File Search Paths if present. ;; lst - [lst] list of paths to remove (case-insensitive), e.g. '("C:\\Folder1" "C:\\Folder2" ... ) ;; Returns: [str] "ACAD" Environment String following modification (defun LM:sfsp- ( lst / pos str tmp ) (setq str (strcat (vl-string-right-trim ";" (getenv "ACAD")) ";") tmp str ) (foreach pth lst (if (/= "" pth) (while (setq pos (vl-string-search (strcase (strcat pth ";")) (strcase str))) (setq str (strcat (substr str 1 pos) (substr str (+ pos (strlen pth) 2)))) ) ) ) (if (/= tmp str) (setenv "ACAD" str)) )
Example Function Call
(LM:sfsp- '("C:\\Folder1" "C:\\Folder2" "C:\\Folder3"))
Wildcard Remove Support File Search Paths
Function Syntax | (LM:wcsfsp- <pat>) |
Current Version | 1.0 |
Donate |
Arguments | ||
---|---|---|
Symbol | Type | Description |
pat | String | Case insensitive wildcard pattern |
Returns | ||
Type | Description | |
String | Value of ACAD environment variable following modification, else nil if unchanged. |
Function Description
This function will modify the semi-colon delimited string value of the ACAD environment variable to remove all paths found to match a supplied wildcard pattern. The set of valid wildcard operators recognised by the function are consistent with those recognised by the standard AutoLISP wcmatch function.
The wildcard pattern supplied to the function is case-insensitive.
;; Wildcard Remove Support File Search Paths - Lee Mac ;; Removes all Support File Search Paths matching a supplied wildcard pattern. ;; pat - [str] Wildcard pattern (case-insensitive) ;; Returns: [str] "ACAD" Environment String following modification, else nil if unchanged (defun LM:wcsfsp- ( pat / wcsfsp- str tmp ) (defun wcsfsp- ( str pat / pos ) (cond ( (or (= "" str) (not (setq pos (vl-string-position 59 str)))) str ) ( (wcmatch (strcase (substr str 1 pos)) (strcase pat)) (wcsfsp- (substr str (+ pos 2)) pat) ) ( (strcat (substr str 1 (+ 1 pos)) (wcsfsp- (substr str (+ pos 2)) pat))) ) ) (setq tmp (strcat (vl-string-right-trim ";" (getenv "ACAD")) ";") str (wcsfsp- tmp pat) ) (if (/= tmp str) (setenv "ACAD" str)) )
Example Function Call
(LM:wcsfsp- "C:\\Folder1*")