findfile

AutoCad AutoLISP Functions

 
findfile
 
 
 

Searches the AutoCAD library path for the specified file or directory

(findfile filename) 

The findfile function makes no assumption about the file type or extension of filename. If filename does not specify a drive/directory prefix, findfile searches the AutoCAD library path. If a drive/directory prefix is supplied, findfile looks only in that directory.

Arguments

filename

Name of the file or directory to be searched for.

Return Values

A string containing the fully qualified file name; otherwise nil, if the specified file or directory is not found.

The file name returned by findfile is suitable for use with the open function.

Examples

If the current directory is / AutoCAD 2005 and it contains the file abc.lsp, the following function call retrieves the path name:

Command: (findfile "abc.lsp")

"C:\\Program Files\\ AutoCAD 2005\\abc.lsp"

If you are editing a drawing in the / AutoCAD 2005/drawings directory, and the ACAD environment variable is set to / AutoCAD 2005/support, and the file xyz.txt exists only in the / AutoCAD 2005/support directory, then the following command retrieves the path name:

Command: (findfile "xyz.txt")

"C:\\Program Files\\ AutoCAD 2005\\support\\xyz.txt"

If the file nosuch is not present in any of the directories on the library search path, findfile returns nil:

Command: (findfile "nosuch")

nil