Reg: autoload function for Lisp

Reg: autoload function for Lisp

Anonymous
Not applicable
1,594 Views
7 Replies
Message 1 of 8

Reg: autoload function for Lisp

Anonymous
Not applicable

 

Hi,

 

I loaded many lisp files by using below autoload function.but some of lisp files failed to load on Startup,but if we load Indiviually its Working Fine.

Whether My load function is wrong,By the way I m not a lisp Programmer,So please anyone Guide me.

 

I saved the Below as Acaddoc.lsp and loaded via Trusted locations.

 

(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/ALIGN_TEXT_ALT.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/ArxLoad.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/AutoBlockBreakV1-7.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/BFind.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/BLCC.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/Block_Annotative_Match_Orientation.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/Boreholes.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/CircularWipeout.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/COLORX.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/CopyRenameBlockV1-5.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/CopySwapTextV1-4.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/DDLyrAdd.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/DDLyrCas.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/DDLyrOn.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/DDLyrTh.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/DTCurve.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/FindReplaceALL.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/HATCHTOOLS.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/IncArrayV1-7.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/LenCal V1.7.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/MacAttV3-1.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/Netload.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/ObjectAlign.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/PTManagerV2-4.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/Random.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/RMS Alert.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/RMS Annotate.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/RMS Config.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/RMS DR2CAD.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/RMS Drainage.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/RMS Miscellaneous.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/RMS MX2CAD.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/RMS NRS2.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/RMS PageSetup.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/RMS Palettes.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/SetoutPoints.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/Steal.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/StripMtext.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/Supersede.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/TabSortV2-2.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/TfNSW Annotate.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/TrialPits.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/UTB.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/VLXLoad.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/WILDCARD SYNTAX.lsp")
(LOAD "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/XRV2.lsp")

 

 

 

Regards,

Dilipan.S

0 Likes
Accepted solutions (1)
1,595 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

Maybe try AUTOLOAD. It loads only when you call its commands.

 

(autoload "C:/Users/***/Autocad/Settings/Support/Apps/OneMtext.lsp" '("1MT0" "TXT2MTXT2" "1MT2" "ATT2TXT"))

... with all commands at the end.

0 Likes
Message 3 of 8

Kent1Cooper
Consultant
Consultant
Accepted solution

Could it be that there are some little typographical errors in the super-file-path prefixes in some of them, or in the file names themselves?  Those are never an issue when you load things manually by navigating and selecting file names, but they might be in spelled-out (load) functions.  One way to avoid the possibility of filepath errors, and to shorten the code quite a lot, is to put the common filepath into a variable so you know it's spelled out exactly the same way in each line of code:

 

(setq base "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/")

(load (strcat base "ALIGN_TEXT_ALT"))

(load (strcat base "ArxLoad"))

(load (strcat base "AutoBlockBreakV1-7"))

.... etc. ....

 

[By the way, you don't need to include the .lsp filetype endings -- it knows what to look for.]

 

Or perhaps even better, with the file names in a list, and (load) applied to them all in one function:

 

(setq lisps '("ALIGN_TEXT_ALT" "ArxLoad" "AutoBlockBreakV1-7" .... etc. ....))

(mapcar

  '(lambda (x)

    (load (strcat "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/" x))

  )

  lisps

)

 

Either way contains that long filepath only once, and leaves you with a lot less to plow through looking for possible misspellings.

Kent Cooper, AIA
Message 4 of 8

Anonymous
Not applicable
Hi Kent Cooper,
It works fine now.Thanks for your answer and response.
Regards,
Dilipan
0 Likes
Message 5 of 8

jdiala
Advocate
Advocate

Why not load all lisp on entire directory without typing the file name. Something like this.

 

(setq path "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/RMS/")
  (mapcar
    (function
      (lambda (x)
        (load (strcat path x))))
  (vl-directory-files path "*.lsp")
)
(setq path nil)
(princ "All lisp loaded!")
(princ)

0 Likes
Message 6 of 8

Kent1Cooper
Consultant
Consultant

@jeri32 wrote:

Why not load all lisp on entire directory without typing the file name. Something like this.

...


That's a good idea if they always want to load every AutoLisp file in that folder.  I know I have a lot of such files in the place where I keep such things that I don't always want loaded [or autoloaded], because I use them only rarely, so I load one only if and when I need it.  But certainly one could make a separate folder for things that should always be loaded, use your suggestion on that folder, and keep things that are used only occasionally in a different folder.

Kent Cooper, AIA
0 Likes
Message 7 of 8

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

.... 

Or perhaps even better, with the file names in a list, and (load) applied to them all in one function:

 

(setq lisps '("ALIGN_TEXT_ALT" "ArxLoad" "AutoBlockBreakV1-7" .... etc. ....))

(mapcar

  '(lambda (x)

    (load (strcat "N:/GLOBAL/APPS RESOURCES/AUTODESK/AUTOCAD/2014/Client Library/2100047/SOC/Lisp/" x))

  )

  lisps

)

....


Now it occurs to me....  If you just put that folder in your Support File Search Path list in Options, and assuming there are no such files with the same names in any other folder(s) in that list, you don't need to spell out the filepath at all!  My acaddoc.lsp file has lots of (load) and (autoload) functions with no filepaths in them, and it finds them because they're in a place where it knows to look.  Simply:

 

(mapcar 'load '("ALIGN_TEXT_ALT" "ArxLoad" "AutoBlockBreakV1-7" .... etc. ....))

Kent Cooper, AIA
0 Likes
Message 8 of 8

scot-65
Advisor
Advisor
>>Now it occurs to me....
🙂

In it's simplest form...

Create a file with key word "Utility" in it. File extension is ".LSP".
Load this file from one of the interface points (acad.lsp, acaddoc.lsp, MyMenu.mnl, etc.).

Inside, declare the keystroke combination, the load, the execution, and a brief
explanation AS A SINGLE LINE:
(defun c:ABC () (load "ABC")(c:ABC) ) ;a simple utility
(defun c:DEF () (load "DefineMe")(c:DEF) ) ;another utility

Lastly, gather all the "stand-alone" LSP files into one folder and declare the folder
in the support path and trusted location areas.

The hint here is to use the same keystroke that is declared inside the LSP file. When
this keystroke is used for the first time, the file is loaded, then executed. It also
redefines the keystroke so as it will not load repeatedly. This can be called
"progressive loading".

When a new routine is introduced, simply drop the file into the folder and update
the Utility file by adding another line.

I do not care for the autoload function as it is command line noisy.

Hope this helps, Dili.

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes