Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp routines and “Support File Search Path”

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
4697 Views, 11 Replies

Lisp routines and “Support File Search Path”

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

11 REPLIES 11
Message 2 of 12
pbejse
in reply to: Anonymous


@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?

 

 

 

Message 3 of 12
pbejse
in reply to: pbejse

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

 

Message 4 of 12
dgorsman
in reply to: pbejse

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.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 5 of 12
Anonymous
in reply to: pbejse

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

Message 6 of 12
Anonymous
in reply to: dgorsman

Hi Dgorsman,

 

I have to digest this.  I am sick tomorrow, so I'll have the time then.

 

Thanks,

 

GS

Message 7 of 12
Kent1Cooper
in reply to: Anonymous


@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.

Kent Cooper, AIA
Message 8 of 12
scot-65
in reply to: Anonymous

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.


Message 9 of 12
pbejse
in reply to: dgorsman


@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

 

 


 

Message 10 of 12
pbejse
in reply to: Anonymous


@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

Message 11 of 12
martti.halminen
in reply to: Anonymous


@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).

 

--

 

Message 12 of 12
pbejse
in reply to: Kent1Cooper


@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?

 

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost