In 2009 what is the best way to load commonly used lisp routines automatically so they are always loaded and ready to go?
In 2009 what is the best way to load commonly used lisp routines automatically so they are always loaded and ready to go?
Add them to your acaddoc.lsp
This file doesn't come with AutoCAD, just create your own if needed, and put it in the path at the TOP of your support file search path. Example:
You could also look into the (autoload) routine which doesn't actually load the lisp file until it's needed.Code:(load "mylisp") (load "\\\\server\\share\\mylispfile_that_is_not_in_the_support_path") (load "another_lisp") (load "one_more") (princ "acaddoc.lsp loaded... ") (princ)
For example:
...makes the commands "myfunc" and "my" available, but doesn't load the actual file (named "mylispfile.lsp") until one of these functions are called.Code:(autoload "mylispfile" '("myfunc" "my"))
Put this (autoload) statement in "acaddoc.lsp" also.
If you have a bunch of tiny lisp files that you want loaded all the time, you could get rid of them all and just consolidate all the code in the "acaddoc.lsp" itself.
See the following link for more info on startup code in general and how to easily migrate this from one version to another: http://cadpanacea.com/node/34
Last edited by rkmcswain; 2009-04-15 at 09:53 PM. Reason: make addition
rkmcswain's is the simplest way of doing this. Just remember that you should never place any custom code in ACADDOC20##.LSP (for ACad version 20## ). The reason is that both the ACAD20##.LSP and ACADDOC20##.LSP files are maintained by AutoDesk and may be overwritten due to an update. Therefore ACad has always allowed you to create your own ACADDOC.LSP which is meant for your own custom code and won't be overwritten by any update, this (as stated) loads every time a drawing is created / opened. You can also create an ACAD.LSP, similar to ACADDOC.LSP but only loads once per session if ACADLSPASDOC=0 default, otherwise it acts the same as ACADDOC.LSP.
Another way is to place a (vl-load-all "PathToLSP\\LispFileName.LSP") in ACAD.LSP. This is only loaded once per AutoCAD session, but available to all DWG's already opened and to be opened in this session. Slight performance advantage if you have numerous and / or large LSP files to load. Unfortunately I don't know of a way to get autoload to work similarly.
Otherwise, the Start-Up suite in APPLOAD is also still available. Basically does the same as the (load ...) in ACADDOC.LSP.
Or another way could be to place (load ...) or (autoload ...) in the MNL file of your custom menu CUI. Or simply add the LSP file to the custom cui's Lisp files section.
Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!