Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I load Lisp routines on demand only?

5 views
Skip to first unread message

Alfredo Medina

unread,
Jan 25, 2003, 9:39:55 PM1/25/03
to
I would appreciate any help on this issue:

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


rdi

unread,
Jan 25, 2003, 10:15:49 PM1/25/03
to
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

(remove the exclamation from the email address)

"Alfredo Medina" <alfm...@hotmail.com> wrote in message
news:34ADB68F86519F7A...@in.WebX.maYIadrTaRb...

Alfredo Medina

unread,
Jan 25, 2003, 10:59:08 PM1/25/03
to
RDI,

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


David Doane

unread,
Jan 26, 2003, 4:35:02 PM1/26/03
to
Perhaps the conversation "Auto load lisp routines" below will help you find what you are searching for.
--
Dave D (ditch the dash to reply)
May you always find Peace, Love, and Happiness in all that you do!

"Alfredo Medina" <alfm...@hotmail.com> wrote in message news:75FC6A9272DF06A5...@in.WebX.maYIadrTaRb...

rdi

unread,
Jan 26, 2003, 4:43:24 PM1/26/03
to
If a.lsp contains 100 lines of text, this will benefit in that it only
contains one line of text that gets loaded via acad.lsp. If you then want
to actually run the command, it loads the util at that time.

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

Martin Schmid

unread,
Jan 26, 2003, 8:26:38 PM1/26/03
to
The AUTOLOAD command does what you want... it loads a lisp file only on
first invocation by the user entering the command as you desire.

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

Kevin Nehls

unread,
Jan 27, 2003, 1:16:02 AM1/27/03
to
However, there are problems with AutoCAD's autoloader. If you want
something better check mine out here:
www.niveksdomain.com/lisp

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

0 new messages