The Abc'S of Autolisp by George Omura: Managing Large Acad - LSP Files

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

The ABCs of AutoLISP by George Omura

Loading acad.lsp...
Now, the box program is available to you without having to manually load it.
Though the Acad.lsp file only contained the box program, you could have included several programs and functions
in that single file. Then, you would have access to several AutoLISP programs by loading just one file.

Managing Large Acad.lsp files


As you begin to accumulate more AutoLISP functions in your ACAD.lsp file, you will notice that AutoCAD takes
longer to load them. This delay in loading time can become annoying especially when you just want to quickly open
a small file to make a few simple revisions. Fortunately, there is an alternative method for automatically loading
programs that can reduce AutoCAD's start-up time.
Instead of placing the programs code in Acad.lsp, you can use a program that loads and runs the program in
question. For example, you could have the following line in place of the box program in the Acad.lsp file:
(defun c:BOX () (load "/lsp/box") (c:box))
We will call this a box loader function. Once the above function is loaded, entering Box at the command prompt
will start it. This box loader function then loads the real Box program which in turn replaces this box loader
function. The (c:box) in the box loader function is evaluated once the actual box program has been loaded thus
causing the box program to run. C:BOX is the symbol representing the program BOX so when it evaluated, like any
function, it will run.
As you can see, this program takes up considerably less space that the actual box program and will therefore load
faster at start-up time. You can have several of these loading programs, one for each AutoLISP function or program
you wish to use on a regular basis. Imagine that you have several programs equivalent in size to the box program.
the Acad.lsp file might be several pages long. A file this size can take 30 seconds to load. If you reduce each of
those programs to one similar to the box loader function above, you substantially reduce loading time. Several pages
of programs could be reduced to the following:
(defun C:PROGM1 () (load "/lsp/progm1") (C:PROGM1))
(defun C:PROGM2 () (load "/lsp/progm2") (C:PROGM2))
(defun C:PROGM3 () (load "/lsp/progm3") (C:PROGM3))
(defun C:PROGM4 () (load "/lsp/progm4") (C:PROGM4))
(defun C:PROGM5 () (load "/lsp/progm5") (C:PROGM5))
(defun C:PROGM6 () (load "/lsp/progm6") (C:PROGM6))
(defun C:PROGM7 () (load "/lsp/progm7") (C:PROGM7))
If you imagine that each of the functions being called from the above example is several lines long then you can see

43
Copyright 2001 George Omura,,World rights reserved

You might also like