Loading Multiple LISP Routines at Once...
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Loading Multiple LISP Routines at Once...
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
abittar
Guest





Posted: Tue Dec 28, 2004 11:59 pm    Post subject: Loading Multiple LISP Routines at Once... Reply with quote

We are trying to load multiple LISP routines at one time. We would like to
load them when AutoCAD is starting up, but do not want to use the acad.lsp
file to accomplish this task.

Thank you in advance.

Back to top
R.K. McSwain
Guest





Posted: Wed Dec 29, 2004 12:05 am    Post subject: Re: Loading Multiple LISP Routines at Once... Reply with quote

abittar wrote:

Quote:
We are trying to load multiple LISP routines at one time. We would like to
load them when AutoCAD is starting up, but do not want to use the acad.lsp
file to accomplish this task.


How about acaddoc.lsp, or <yourmenu>.MNL, or ....... well, there are
many ways.

Without knowing why you don't want to use 'acad.lsp', it's hard to say
which option might work best for you.
Back to top
Tom Smith
Guest





Posted: Wed Dec 29, 2004 12:10 am    Post subject: Re: Loading Multiple LISP Routines at Once... Reply with quote

If you want them available in every drawing, then you'd need to use
acaddoc.lsp rather than acad.lsp. A lisp loaded in one drawing isn't
normally available in another. Other possibilities are to do the loading in
an mnl file associated with a menu (which loads in every drawing), or to add
a loader-upper lisp file to the startup suite. I don't like the latter
approach because I don't know a way to propagate it on multiple machines
without manually running appload on each computer.

Also, I much prefer autoloading rather than loading lisp functions,
especially if there are many to load. The difference is, there's no delay on
startup with autoload -- the lisps aren't actually loaded until they're
needed.

One method I use is to compile multiple lisps into one vlx, then autoload
that file in your statup sequence, e.g.(autoload "lispcollection.vlx"
'("cmd1" "cmd2" etc)). Again, there's a performance limit on how many lisps
you want to include in the one vlx. You don't want a long pause the first
time a person enters a command which triggers the loading. By experiment, on
our computers, I found that around 30K of lisp per vlx didn't cause a
noticeable delay.

Back to top
R.K. McSwain
Guest





Posted: Wed Dec 29, 2004 12:27 am    Post subject: Re: Loading Multiple LISP Routines at Once... Reply with quote

Tom Smith wrote:
Quote:
If you want them available in every drawing, then you'd need to use
acaddoc.lsp rather than acad.lsp.

Only if ACADLSPASDOC is set to 0.
A setting of 1 loads acad.lsp in every drawing opened.
Back to top
Tom Smith
Guest





Posted: Wed Dec 29, 2004 12:35 am    Post subject: Re: Loading Multiple LISP Routines at Once... Reply with quote

Quote:
Only if ACADLSPASDOC is set to 0.
A setting of 1 loads acad.lsp in every drawing opened.

True. The default is 0. Setting it to 1 defeats the potentially very useful
dustinction between the two files.
Back to top
ecable
Guest





Posted: Wed Dec 29, 2004 12:45 am    Post subject: Re: Loading Multiple LISP Routines at Once... Reply with quote

We have a custom menu on the server that everyone is mapped to (company.MNS) and a company.MNL in the same location.
All of the .VLX and .LSP files that are use frequently are loaded from the company.MNL.
Any other .LSP or .VLX files are called from the menu ie.
(if (not c:somelisp (load "somelisp")(princ)) somelisp.
Back to top
ecable
Guest





Posted: Wed Dec 29, 2004 12:48 am    Post subject: Re: Loading Multiple LISP Routines at Once... Reply with quote

Oops
(if (not c:somelisp)(load "somelisp")(princ)) somelisp
Back to top
Tom Smith
Guest





Posted: Wed Dec 29, 2004 1:02 am    Post subject: Re: Loading Multiple LISP Routines at Once... Reply with quote

Quote:
All of the .VLX and .LSP files that are use frequently are loaded from the
company.MNL.
Any other .LSP or .VLX files are called from the menu ie.
(if (not c:somelisp (load "somelisp")(princ)) somelisp.

Syntax error in last line.

I don't like loading any lisps at startup because of the time wasted
compared to the autoload technique. I don't distinguish between frequently
used and otherwise, because I've learned that usage varies wildly among
users. I autoload everything, in small doses, so that nothing's loaded until
it's called, and there's never a delay waiting for this to happen.

I don't put any of the (if (not "blah") (load "blah"));blah; business in a
menu item, because it's just repetitive clutter. That's what mnl's were
intended for, to get the lisp out of the menu and to eliminate the question
of whether a lisp had been loaded. If the mnl says (autoload "blah"
'("blah")) then there's no reason to use anything more than ^c^cblah; for
the menu item.
Back to top
ecable
Guest





Posted: Wed Dec 29, 2004 4:58 pm    Post subject: Re: Loading Multiple LISP Routines at Once... Reply with quote

I didn't know about autoload. I just looked it up and it looks to be the way to go.
The help file doesn't say anything about a VLX file, but I am assuming that will work as well.
I am getting ready to write a new menu and I will have to try autoload.

Thanks for the information.
Back to top
Tom Smith
Guest





Posted: Wed Dec 29, 2004 6:21 pm    Post subject: Re: Loading Multiple LISP Routines at Once... Reply with quote

Quote:
The help file doesn't say anything about a VLX file, but I am assuming
that will work as well.


It takes a small tweak. There's a silly oversight in Acad's autoloader in
that it doesn't accept FAS or VLX files.

My loader-upper file, which is loaded by an mnl, consists of a number of
autoload statements. In that file, I redefined the ai_ffile function found
in acad2004doc.lsp as follows:

(defun ai_ffile (app)
(or (findfile (strcat app ".lsp"))
(findfile (strcat app ".exp"))
(findfile (strcat app ".exe"))
(findfile (strcat app ".arx"))
(findfile (strcat app ".fas"))
(findfile (strcat app ".vlx"))
(findfile app)))

This allows autoload to work with FAS and VLX files as well as the other
types.

For performance reasons (e.g. not waiting for things to load) I compile any
single lisp larger than about 5 or 10K as a FAS file and use a statement
like (autoload "jack" '("jack")). For multiple small lisps, I compile them
into VLX's in bunches of about 20 or 30K, and use a statement like (autoload
"lisp1" '("addbp" "alloff" "arrow" "bkln" "chglayer" "date")). In that
example, lisp1.vlx will load the first time the user issues any of the
commands listed.
Back to top
ecable
Guest





Posted: Wed Dec 29, 2004 11:09 pm    Post subject: Re: Loading Multiple LISP Routines at Once... Reply with quote

Thanks Tom.
This gives me a whole new perspective on loading my routines.
Have a great New Year.

Ed Cable
Back to top
Tom Smith
Guest





Posted: Wed Dec 29, 2004 11:23 pm    Post subject: Re: Loading Multiple LISP Routines at Once... Reply with quote

You're welcome, same to you Ed.

Load time isn't as noticeable as it used to be on slower machines, but it
can make a big difference if you're automating things, as in running a
script on multile drawings.

I've even made myself another profile purely for scripting, which has no
menu at all and therefore, all of our custom stuff is disabled. I'll set up
the script to only load whatever lisps are actually needed. I found that
drawings will open at least three times as fast in a script, on my computer,
if there's no menu loaded. That's a big difference if you're processing many
files.
Back to top
Rogerio_Brazil
Guest





Posted: Thu Dec 30, 2004 12:01 am    Post subject: Re: Loading Multiple LISP Routines at Once... Reply with quote

Try adding the routines to Startup Suite.

Type Appload, in dialog box press the button "Contents",

select the routines and close. In the next autocad section,

the routines are loadeds.

[]s,

Rogério
Back to top
ecable
Guest





Posted: Thu Dec 30, 2004 1:11 am    Post subject: Re: Loading Multiple LISP Routines at Once... Reply with quote

That's a good idea. I run scrips on whole directories of drawings occasionally, and never thought to create a profile for just that purpose.

Thanks again.

Ed Cable
Back to top
Matt Stachoni
Guest





Posted: Fri Dec 31, 2004 9:05 pm    Post subject: Re: Loading Multiple LISP Routines at Once... Reply with quote

On Tue, 28 Dec 2004 15:02:15 -0500, "Tom Smith" <nospam> wrote:

Quote:
I don't like loading any lisps at startup because of the time wasted
compared to the autoload technique. I don't distinguish between frequently
used and otherwise, because I've learned that usage varies wildly among
users. I autoload everything, in small doses, so that nothing's loaded until
it's called, and there's never a delay waiting for this to happen.

But there are times when you would want to normally load a LSP file in each and
every drawing, e.g. if you offer your users a standard "macros" type of
application that has many company-wide keyboard macros as a
replacement/enhancement for acad.pgp.

If you try to autoload this, you'd had to define an Autoload expression for each
and every command, which could get daunting if you have many of them, and you'd
always have to sync the source macros file with the autoload expression, which
adds a bit of admin overhead.

Currently I autoload a standard "macros.vlx" package - using a modified
(ai_ffile) function that is STILL not fixed in 2005 - that contains hundreds of
keyboard macros. It's about 300K, yet doesn't cause a noticable delay in loading
for my 30-odd users.

The other thing I do is separate standard functions into separate library VLX
files, and "demand load" those libraries as required. That lessens the code
required in the macros and utilities. I currently have about 20 separate library
files for handling different types of tasks (registry, file I/O, blocks, text,
strings, etc.)

For times when one wants to turn off autoloading a "big" application like
macros.vlx (for speed or whatever), you could offer your users the option of not
autoloading it using a simple "flag" function (in acaddoc.lsp) which uses
(getenv) and (setenv) to read/write to the user's Registry...

(defun ToggleMacrosLoad (/ v)
(setq v (getenv "LoadMacros"))
(if v
(setenv "LoadMacros" (abs (1- v)))
(setenv "LoadMacros" 1) ;;default value = enabled
)
(princ)
)

...., which can accessed in a menu using DIESEL:
[$(if,$(eq,$(getenv,LoadMacros),1),!.)Load macros in every
drawing]^c^c^p(ToggleMacrosLoad)

And in your S::STARTUP function, use this expression to load them:
(if (= 1 (getenv "LoadMacros")) (load "Macros.vlx"))

Matt
mstachoni@comcast.net
mstachoni@bhhtait.com
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB