I have an acaddoc.lsp file with a long list of Lisp routines that I load in every
drawing. Loading this takes some seconds, not many but if I continue increasing the
list, in the long run the time to start each drawing will increase as well. So I would
like to find a way of having the Lisp routines load only on demand. For example,
routine "A" will be loaded in the drawing only the user needs invokes the command by
a button or menu. How can I do that? I tried typing in one of my buttons something
like (load "a")^c^cA ; meaning load A and execute A, assuming that there is a routine
called "a.lsp" which has a function named as "(Defun c:A)" Well, that does not work.
So, I am still loading "A" even though it might not be used in the drawing session. I
would like to avoid this. Can anybody please explain how to do this?
Alfredo Medina
Then in your acad.lsp file, put the following (autoload "a" '("a" "b")) this
is the equivalent of doing (defun c:a()(load "a")(c:a)) (defun c:b()(load
"b")(c:b)).
Now when you type a it will load your routine then run it.
--
RDI
(remove the exclamation from the email address)
"Alfredo Medina" <alfm...@hotmail.com> wrote in message
news:34ADB68F86519F7A...@in.WebX.maYIadrTaRb...
Is that going to avoid loading the "A" routine in the drawing? It seems that you are
loading "A" anyway from acad.lsp. Am I right?
I would like to load it only at the moment when the routine is going to be used, not
before.
Thank you.
Alfredo Medina
"rdi" <rdi!@writeme.com> wrote in message
news:DE0526B680946862...@in.WebX.maYIadrTaRb...
> Using your example, if you have a file "A.lsp" which contains (defun c:a()
> do something......) & I'll throw in another (defun c:b()do something else).
>
> Then in your acad.lsp file, put the following (autoload "a" '("a" "b")) this
> is the equivalent of doing (defun c:a()(load "a")(c:a)) (defun c:b()(load
> "b")(c:b)).
>
> Now when you type a it will load your routine then run it.
> RDI
>
(...)
"Alfredo Medina" <alfm...@hotmail.com> wrote in message news:75FC6A9272DF06A5...@in.WebX.maYIadrTaRb...
Which of the following would be preferable?
(defun c:a()
(load "a")
(c:a)
)
or
(defun c:a()
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
(something)
)
--
RDI
(remove the exclamation from the email address)
"Alfredo Medina" <alfm...@hotmail.com> wrote in message
news:75FC6A9272DF06A5...@in.WebX.maYIadrTaRb...
From the help files:
---------------------------
autoload
Predefines command names to load an associated AutoLISP file
(autoload filename cmdlist)
The first time a user enters a command specified in cmdlist, AutoCAD loads
the application specified in filename, then continues the command.
Arguments
filename
A string specifying the .lsp file to be loaded when one of the commands
defined by the cmdlist argument is entered at the Command prompt. If you
omit the path from filename, AutoCAD looks for the file in the Support File
Search Path.
cmdlist
A list of strings.
Return Values
nil
If you associate a command with filename and that command is not defined in
the specified file, AutoCAD alerts you with an error message when you enter
the command.
Examples
The following causes AutoCAD to load the bonusapp.lsp file the first time
the APP1, APP2, or APP3 commands are entered at the Command prompt:
(autoload "BONUSAPP" '("APP1" "APP2" "APP3"))
"Alfredo Medina" <alfm...@hotmail.com> wrote in message
news:75FC6A9272DF06A5...@in.WebX.maYIadrTaRb...
There are examples in the file, it's similar to AutoCAD's autoload
function, but not exactly the same and it's better ;)
AutoCAD's Autoloader will:
1) Throw you into an infinite loop if the file loaded doesn't redefine
the function/command that is to be called.
2) It can't autoload functions with arguments, it can and will only
autoload C: type functions.
3) You can specify the path to the file if the file is not in your
support path.
4) The only way to autoload a FAS or VLX file it so specify the
extension. This is not the most desired behavior since it is not the
same as the regular load function.
Cheers,
Kevin