Hi,
It might be a silly question, but: Is there a way to have a sub-directory support file system where one has only have to add the root directory to the “Support file Search Path” section in Options? If there is it were easier to categorize/maintain a whole slew of routines.
Like this: Lisp_Programs would be the main directory and it is added to “Support file Search Path”.
Files_1, Files_2 etc. are the subdirectories are not referenced inn the “Support file Search Path” section.
Lisp_Programs\
Files_1
Files_2
Files_3
Files_4
Files_5
Thank you,
GS
@Anonymous wrote:Hi,
It might be a silly question, but: Is there a way to have a sub-directory support file system where one has only have to add the root directory to the “Support file Search Path” section in Options? If there is it were easier to categorize/maintain a whole slew of routines.
Like this: Lisp_Programs would be the main directory and it is added to “Support file Search Path”.
Files_1, Files_2 etc. are the subdirectories are not referenced inn the “Support file Search Path” section.
Lisp_Programs\
Files_1
Files_2
Files_3
Files_4
Files_5
Thank you,
GS
(vla-put-supportpath
(setq files (vla-get-files (vla-get-preferences (vlax-get-acad-object))))
(strcat ";C:\\Lisp_Programs\\Files_1"
";"
(vla-get-supportpath files)
)
)
Are these folder already exists?
You only need to this one time , so why not add them on the
_options/file/Support File Search Path?
try this
(defun c:AddToSFSP (/ files path fldrs) (setq _Ad (lambda (s) (strcat path s ";"))) (setq files (vla-get-files (vla-get-preferences (vlax-get-acad-object)))) (vl-mkdir (setq path (strcat (findfile "\\.") "Lisp_Programs\\"))) (foreach dir (setq fldrs '("Files_1" "Files_2" "Files_3" "Files_4" "Files_5")) (vl-mkdir (strcat path dir "\\"))) (vla-put-supportpath files (strcat (apply 'strcat (mapcar '_Ad fldrs)) (vla-get-supportpath files)) ) (princ) )
It will create the folders for you and add them to SFSP
Right now it creates the folders on the current root drive of your drawing, you can change the code to whatever drive you want.
(setq path (strcat "D:\\Lisp_Programs\\"));<-- hard coded
***** You dont need to worry if the folders are already exists and the directories are included in the SFSP****
it will not override nor delete the exisitng folder/files
HTH
You don't always want to be adding lots of extraneous folders - not only can it extend search times everytime something goes to the SFSP to find a file, but I've found that crashing AutoCAD with a total path length of greater than 1024 characters (including semi-colons and path delimiters) causes the search path to be truncated when AutoCAD is re-started.
To the OP, you have a number of options. Perhaps the best would be to establish a registry setting or three, with search paths stored there. Very easy to set up and maintain. You can then use a modified version of a recursive file search using those paths. As an alternative you could use a loader LISP routine which establishes a dotted-pair list of paths such as ("index string" . "X:\\Some\\path\\here") for common reference. I have something of a hybrid of the two systems, where the search function takes an argument of either nil (use SFSP) or a list of folders, along with a maximum nest depth.
I haven't tried it yet, but "AddToSFSP" seems to add the paths to the SFSP. It is a nice auto solution, but I was looking for a something where a lisp-load-program (w/out lines for each lisp) loads routines from the sub-directories w/out adding the paths to the SFSP.
Something along the lines of Relative Xref Paths, even though that is a bit hokey in my opinion.
By the way, what is the limit to the SFSP? Also, do a lot of paths slow down AutoCAD?
Thanks,
GS
@Anonymous wrote:....
It might be a silly question, but: Is there a way to have a sub-directory support file system where one has only have to add the root directory to the “Support file Search Path” section in Options?....
I don't think so. Our ArchDesktop2004 came with these in the SFSP list by default [in addition to a couple of \Documents and Settings\ ones, and we've added a few]:
C:\Program Files\Autodesk Architectural Desktop 2004\Support
C:\Program Files\Autodesk Architectural Desktop 2004\Fonts
C:\Program Files\Autodesk Architectural Desktop 2004\Help
C:\Program Files\Autodesk Architectural Desktop 2004\Express
C:\Program Files\Autodesk Architectural Desktop 2004\Support\Color
If having a folder listed would let it also find things in sub-folders beneath that, then the last of the above wouldn't be needed. And if it would, and they covered all the above locations with one item, spelled out just through the "...Desktop 2004" part, without adding the subfolders beneath that, then AutoCAD would need to also look in the many other subfolders [27 total] that are in there, but that don't contain anything it will ever be looking for.
I would try VL-FILENAME-DIRECTORY, then hard-path the rest of it.
For instance, I have a file name "ABC.lsp" in the "Lisp_Programs" folder.
The "Lisp_Programs" folder is declared as a support path.
Then STRCAT, and FINDFILE to finish up.
(vl-load-com)
(load (strcat (VL-FILENAME-DIRECTORY (findfile "ABC.lsp")) "\\Files_1\\DEF.lsp"))
untested.
To further avoid errors, look into VL-DIRECTORY-FILES (-1) to see if sub-directories are present.
???
Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.
@dgorsman wrote:You don't always want to be adding lots of extraneous folders - not only can it extend search times everytime something goes to the SFSP to find a file, but I've found that crashing AutoCAD with a total path length of greater than 1024 characters (including semi-colons and path delimiters) causes the search path to be truncated when AutoCAD is re-started.
Thank you for the info dgorsman. I will look into that.
Cheers
@Anonymous wrote:I haven't tried it yet, but "AddToSFSP" seems to add the paths to the SFSP. It is a nice auto solution, but I was looking for a something where a lisp-load-program (w/out lines for each lisp) loads routines from the sub-directories w/out adding the paths to the SFSP.
Something along the lines of Relative Xref Paths, even though that is a bit hokey in my opinion.
Well you did asked how to add directories to SFSP.
Might as well use acaddoc.lsp and lisp code at the ready.
The path would be hard-coded
(load "C:\\Lisp_Programs\\Files_1\\MyTextEditLisp.lsp" "MyProgram Failed to Load.")
One disadvantage of using the load function arises when the user wishes to load a large number of programs. -- LM
or a better option
(autoload "C:\\Lisp_Programs\\Files_1\\MyTextEditLisp.lsp" '("TheCommand"))
(autoload "C:\\Lisp_Programs\\Files_1\\MyTextEditLisp.lsp" '("TheCommand1" "TheCommand2"))
The first time a user enters a command specified in cmdlist, AutoCAD loads the application specified in filename, then continues the command.-- Autocad Help
upon the user typing a command present in the list, the filename supplied will be loaded into the current drawing session-- LM
@Anonymous wrote:By the way, what is the limit to the SFSP? Also, do a lot of paths slow down AutoCAD?
Thanks,
GS
Yes it does slow down. as for limit. read dgorsman post.
HTH
@Anonymous wrote:Hi,
It might be a silly question, but: Is there a way to have a sub-directory support file system where one has only have to add the root directory to the “Support file Search Path” section in Options? If there is it were easier to categorize/maintain a whole slew of routines.
Like this: Lisp_Programs would be the main directory and it is added to “Support file Search Path”.
Files_1, Files_2 etc. are the subdirectories are not referenced inn the “Support file Search Path” section.
Lisp_Programs\
Files_1
Files_2
Files_3
Files_4
Files_5
Thank you,
GS
I'd recommend doing this in another way, assuming your programs aren't mutually exclusive:
- Build whatever source directory structure you like
- Use VLIDE to define a project where all these programs are collected, so the directory information is written to the project definition file.
- Compile the whole into a .VLX application.
So, you have just one (or a few) .vlx file(s) to include on the path (or load through acaddoc.lsp etc. without changing the path at all).
--
@Kent1Cooper wrote:
If having a folder listed would let it also find things in sub-folders beneath that, then the last of the above wouldn't be needed. And if it would, and they covered all the above locations with one item, spelled out just through the "...Desktop 2004" part, without adding the subfolders beneath that, then AutoCAD would need to also look in the many other subfolders [27 total] that are in there, but that don't contain anything it will ever be looking for.
Can anyone verify this?
I tried
(findfile "banana.dwg") --- > nil
also
(command "_insert" "banana.dwg" ) --> Can't find file in search path:
knowing the file is one sub-folder down from a known fodler included in the SFSP.
Or are there other ways of testing the SFSP?