Some people are having problems loading files so they are available when needed.
The options are either to load everything at the start
or to have some sort of demand-load mechanism in place.
There are issues with the AutoCAD 2013 Startup Suite loading lsp files
so I thought I'd post a modified version of the mechanism I have used
sucessfully for about 10 years.
The sample files are included in a Zip ...
just drop the lot into a folder that is on the AutoCAD path.
In AutoCAD menuLoad the partial menu 'MyPersonalMenu.MNU'
Once the partial menu is loaded it will load each time you open a session.
The file 'MyPersonalMenu.MNL' will load automatically when the MNU loads.
This file is used to load files I need in each document namespace
and to define 'stubs' for any functions/commands I want to be DEMAND-loaded.
The file 'KDUB_DemandLoader.LSP' has documentation
and the samples in MyPersonalMenu.MNL can be followed.
If you dont want the files loaded just unload the partial menu
or comment out the stub declaration in the .MNL file.
As you develop new functions/command just add the relevant AutoLoad stub
to the MNL file and distribute it with the new/revised code files.
The System works with compiled files.
It works for Commands and methods.
It allows stubs to be defined with parameters.
Using this methodology initial load time and memory use is reduced considerably
... code files are not loaded untill thy are needed.
I look forward to Comments
Regards
Kerry
// MyPersonalMenu.MNU
//============================================================================
// $Header: $
//
// codeHimBelonga kdub@theSwamp 2012.04.20
***MENUGROUP=MYPERSONALMENU
***POP19
[KDUB_TestMenu_Sample]
[Test 5]^C^CTest5;
[Test 3]^C^CTest3;
***TOOLBARS
;;codeHimBelonga kdub@theSwamp
;; MyPersonalMenu.MNL
;;============================================================================
;; KDUB:AutoLSPLoad is defined in ..../Support/acad2012doc.lsp
(load "KDUB_DemandLoader.LSP") )
(prompt "\n MyPersonalMenu.MNL Build 2012.04.20 ....")
(KDUB:AutoLSPLoad "Test01.lsp" '(("test1a") ("Test1b")))
(KDUB:AutoLSPLoad "Test02.lsp" '(("c:test2")))
(KDUB:AutoLSPLoad
"Test03"
'(("c:test3") ("test3a") ("test3B" "Str1" "Str2"))
)
;; command alias definition
(ThisIsAReallyLongMethodNameThatIsUnlikelyToBeDuplicated)
)
(KDUB:AutoLSPLoad
"Test04"
'(("ThisIsAReallyLongMethodNameThatIsUnlikelyToBeDuplicated"))
)
(KDUB:AutoLSPLoad "Test05.FAS" '(("c:test5")))
;;;============================================================================
;; KDUB_DemandLoader.LSP
;| KDUB:autolspload
Usage and Notes:
Adapted by kwb 2002 Aug 29
from posting to newsgroup by Kevin J. Nehls 3-31-2002
(KDUB:autolspload "<filename>"
'(("<func1_name>" "<arg1>" "<arg2>") ("<func2_name>" "<arg1>"))
)
(KDUB:autoarxload "<filename>" '(("<func1_name>" "<arg1>") ("<func2_name>")))
Example 1:
(KDUB:AutoLSPLoad "lspExample1" '(("C:cmd1") ("C:cmd2")))
Example 2:
(KDUB:AutoLSPLoad "lspExample2" '(("KDUB:EX2" "str1" "str2" "real" "int")))
KDUB:AutoARXLoad works exactly the same way as KDUB:AutoLSPLoad only for ARX files
Just add your KDUB:AutoxxxLoad statements to the end of this file or have
this file load
another file which has these statements.
1) Default support for VLX and FAS files without having to specify
the file extension.
2) It can KDUB:AutoXXXLoad any function with any number of arguments.
3) It won't throw you into an infinite loop if the file loaded
doesn't redefine the function/command that is to be called.
--AutoCAD's AutoLoader will do this.
If this happens you now get a message telling you where the
error occured.
--AutoCAD's AutoLoader does not do this.
4) If you want to autoload a command line command you have to
prefix it with C:, see Example 1.
5) To have multiple fuctions/commands autoloaded from the same
file, just add the additional functions as shown in the examples
6) There is no error handling in this AutoLoader. The only reason you
would have it is if the file you were loading was "self-executing".
I have my functions/routines handle the error handling and don't
need the AutoLoader to do this.
7) This AutoLoader currently needs to have AutoCAD 2000 or newer installed
to work just becuase of the use of (vl-filename-extension). You can
easily add support for just about all previous versions that support
the AutoLISP functions used by either removing that or just looking
at the last four chars and determining if it's an extension or not.
|;
(apptyp cmdfile cmdlst / cmdnam arglst cmdpfile)
arglst ""
)
)
)
"(defun "
cmdnam
" ("
arglst
" / tst)"
"(princ \"\nInitializing....\")"
"(setq tst "
cmdnam
")"
"(if (KDUB:autoloaderFindFile "
cmdpfile
")"
(strcat "(progn (load " cmdpfile
")") cmdpfile
")"
)
)
"(if (/= tst "
cmdnam
")"
"("
cmdnam
" "
arglst
")"
"(KDUB:autoloaderNoReDefun "
"\""
apptyp
"\""
" "
"\""
cmdnam
"\""
")
)
)"
"(KDUB:autoloaderNoFile "
cmdpfile
")
)"
")"
)
)
)
)
)
)
cmdlst
)
nil
)
;;;---------------------------------------------------------------------------------
(DEFUN KDUB:autoloaderFindFile
(appnam
) )
)
;;;---------------------------------------------------------------------------------
(DEFUN KDUB:autoloaderNoFile
(appnam
) appnam
"\""
"(.vlx/.fas/.lsp/.arx) "
" "
)
"was not found in your search path folders.\n"
"Check the installation of the support files and try again."
)
)
)
;;;---------------------------------------------------------------------------------
(DEFUN KDUB:autoloaderNoReDefun
(apptyp cmdnam
) "Load for function/command:\n\n\""
"\""
"\""
)
)
)
;;;---------------------------------------------------------------------------------
(DEFUN KDUB:autolspload
(appnam cmdlst
) (KDUB:autoloader
"lsp" appnam cmdlst
)) ;;;---------------------------------------------------------------------------------
;;;---------------------------------------------------------------------------------
;;codeHimBelonga kdub@theSwamp
;; Test00.LSP
;; library file containing routines and functions to be loaded in each drawing
;;============================================================================
;;codeHimBelonga kdub@theSwamp
;; Test02.LSP
;;============================================================================
;;codeHimBelonga kdub@theSwamp
;; Test03.LSP
;;============================================================================
(defun test3a
() (test3b
"Fred" "Bloggs") (princ)) ;;============================================================================
(alert "This is command test3") (test3a)
)
;;============================================================================
(defun test3B
(FirstStr LastStr
/ result
) (strcat "This is function test3b" "\n Result is :" result
) )
)
;;============================================================================
;;codeHimBelonga kdub@theSwamp
;; Test04.LSP
;;============================================================================
(defun ThisIsAReallyLongMethodNameThatIsUnlikelyToBeDuplicated
()
"Function : "
"ThisIsAReallyLongMethodNameThatIsUnlikelyToBeDuplicated"
"\n"
"Loaded from Test04.LSP"
)
)
)
;;codeHimBelonga kdub@theSwamp
;; Test05.LSP
;;============================================================================
;; (vlisp-compile 'st "K:\\TEST\\TEST05.lsp" "K:\\TEST\\TEST05.fas")
;;============================================================================
... The source :