Loading Lisp programs

Lisp program files that can be used with BricsCAD usually have one of these extensions: .lsp, .mnl (file related to a menu) or .des (encrypted file). In most cases Lisp files with the .lsp extension are plain text files.

Loading Lisp programs manually

There are a number of options to load Lisp programs in BricsCAD. You can:

  • Drag-and-drop the file onto an open drawing on Windows®.
  • Use the _Appload command.
  • Type (load "NameOfTheLispFile.lsp"), where the Lisp file must be in the search path. It is possible to leave out the .lsp and .des extensions.
  • Type (load "C:/SomeFolder/NameOfSomeOtherLispFile.lsp"). On Windows® you can use double backslashes or single forward slashes as the path separator. Other operating systems only allow single forward slashes.

Loading Lisp programs automatically

Again there are several options. You can:

Use the _Appload command

In BricsCAD V17 the _Appload command has been revised. For each application file you can specify if it should load automatically.

Use on_doc_load.lsp

To load Lisp programs automatically you can also use the on_doc_load.lsp file. To check if this file already exists type this in the Command Bar: (findfile "on_doc_load.lsp"). If the file is missing you can easily create one using Notepad or any other plain text editor. Because BricsCAD must be able to find the file it is essential to put it somewhere in the search path.

An on_doc_load.lsp may have this content:

(load "NameOfTheLispFile.lsp")
(load "C:/SomeFolder/NameOfSomeOtherLispFile.lsp")
(princ "\nLisp files have been loaded. ")

Use on_doc_load.lsp and autoload

Loading many Lisp programs whenever a drawing is opened can slow things down. Using the autoload mechanism is then a good idea. To use it you have to know the Lisp commands that are defined in the Lisp file. Lisp commands are Lisp functions that have names starting with c: or C:. Let's say you have three Lisp commands: C:CMD1, C:CMD2 and C:CMD3, in the file MyCommands.lsp. To autoload this file insert the following line in on_doc_load.lsp:

(autoload "MyCommands" '("CMD1" "CMD2" "CMD3"))

MyCommands.lsp will now be automatically loaded only when you use one of your Lisp commands. Because no path is provided MyCommands.lsp must be in the search path.

Use the .mnl extension

Lisp files can also be automatically loaded with a menu file (a file with the .cui extension). Giving a Lisp file the same base name as a menu file with the extension .mnl, and placing it in the same folder as the menu file, will ensure that the file is loaded together with the menu.