Author Topic: Load a lisp routine once at start up  (Read 2566 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Load a lisp routine once at start up
« on: July 11, 2013, 12:53:24 AM »
Hello guys .

Is it possible to load a specific lisp routine once at the start up of Autocad and not on every opened drawing ?

Many thanks for you all  :-)

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Load a lisp routine once at start up
« Reply #1 on: July 11, 2013, 01:51:15 AM »
Look into the difference between the ACAD.LSP and ACADDOC.LSP files. They are exactly what you're after. Ensure they're in one of the folders on your Support Folder Search Paths so autocad can find it. And leave the ACADLSPASDOC system variable as default = 0, so the ACAD.LSP works as intended (instead of it being yet another ACADDOC.LSP file).

Inside these files you can simply add a line like
Code - Auto/Visual Lisp: [Select]
  1. (load "yourlispfilename")
If your LSP file is also on the SFSP. If not that line will have to include the path to your file.

Note: ACAD.LSP & ACADDOC.LSP are files you need to create yourself. DO NOT use the ACAD20##.LSP and ACADDOC20##.LSP files which are part of the acad install, and could thus be overwritten by an update / hotfix from adesk - overwriting your hard work.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Load a lisp routine once at start up
« Reply #2 on: July 11, 2013, 01:54:59 AM »
Hi,

If the ACADLSPASDOC sysvar is set to 0 (default) the acad.lsp file is only loaded into the first drawing of a session.

<EDIT: irneb was faster...>
Speaking English as a French Frog

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Load a lisp routine once at start up
« Reply #3 on: July 11, 2013, 04:09:07 AM »
Be aware that a typical lisp is defined at the document level, meaning the current drawing active when the lisp is loaded will be the only drawing where it will be accessible. It is possible to create a lisp that can work in all drawings, but I believe it requires that it be a compiled lisp file. So, when the drawing that was open when the lisp was loaded is closed, the lisp will no longer work. Also, a lisp will not load until a drawing is opened.

There is another way you can load lisp files .. and that is by using the startup suite for your workspace/user profile. However, that will load the lisp in every drawing.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Coder

  • Swamp Rat
  • Posts: 827
Re: Load a lisp routine once at start up
« Reply #4 on: July 11, 2013, 05:38:01 AM »
That's very cool and exactly what I am after  :wink:

Thank you irneb for that great support and nice explanation as always .

Great thanks to gile and Keith as well  :-)

Wonderful team in this amazing forum .


irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Load a lisp routine once at start up
« Reply #5 on: July 11, 2013, 06:06:40 AM »
That's very cool and exactly what I am after  :wink:
More than welcome! I'm always glad to be of some help.

Be aware that a typical lisp is defined at the document level
There is of course the vl-load-all function. You can basically add it into the ACAD.LSP file as you would a normal load call. The difference here is that it's loaded into all open DWGs as well as any future opened DWGs through that one call, it's as if it's loaded throughout all document spaces in one go.

Another thing which you might need to watch out for: If you set a global variable to some value, that value is only inside the currently open DWG's document space. If you swap to another DWG, that value is not available there. To set a variable across all open DWG's an any future opened DWG's you can use vl-propagate. Or using the "black-board" through the vl-bb-set & vl-bb-ref - those are like a separate namespace which you can refer to from any document's namespace.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.