
Originally Posted by
Yancka
Iv'e just read though all threads about loading routines but still didn't found an answer. The concept is to have 1 LISP (say, load.lsp) file which runs at AutoCAD startup and loads all of my LISP routines and some other routines (probably VBA). This would be as a common Startup Suite. If I want users to have a new routine I just add it to load.lsp file and they have it.
What's the way to load another LSP or VLX file within LISP routine? I know (load "name of LSP or VLX"). Is there a way to point specific file in specific location, like (load "Z:\LISP\MyLispRoutine")?
What's the way to load VBA routine file within LISP routine?
I think I've already read about this concept before a while here in AUGI I just don't succeed to find the thread.
Question to those who use acad.lsp, acaddoc.lsp or Start-up Suite to manage custom routines in multi-user environment: if you have 100 users and want to empower them with new super-time-saving-routine what do you do? Use shared acad.lsp, acaddoc.lsp or Start-up Suite? Or may be you use other methods how to empower your users with good tools?
I use shared acad.lsp and acaddoc.lsp. Inside the acaddoc.lsp is the following code:
Code:
(vl-load-com) ; Load COM just in case it's needed
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Routine: load_with_error ;;;
;;; Purpose: Load lisp files with error reporting and exit on error ;;;
;;; Arguments: FileList - list of lisp filenames to load ;;;
;;; Returns: Nothing of value ;;;
;;;-----------------------------------------------------------------------------;;;
;;; If any of the files fail to load this routine will raise an alert box with ;;;
;;; the error and each file that failed, then will exit the calling routine. ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun load_with_error (filelist / errors results)
(setq
results (mapcar (function
(lambda (file) (vl-catch-all-apply 'load (list file)))
)
filelist
)
)
(if (setq errors (vl-remove-if-not
(function (lambda (f) (vl-catch-all-error-p f)))
results
)
)
(progn
(alert
(apply
'strcat
(mapcar (function
(lambda (er) (strcat (vl-catch-all-error-message er) "\n"))
)
errors
)
)
)
(exit)
)
)
)
(load_with_error
(list
"Split"
"logging"
"QKeys"
"Brd_ttlswap"
)
)
(if (setq PersonalLisp (findfile (strcat (getvar "loginname") ".lsp")))
(load_with_error (list personallisp))
)
There are two keys to this working well. First is the QKeys file. This is a lisp file that contains aliases to my lisp routines. Here is a snippet from that file:
Code:
(defun c:login () (load "log") (c:login)) ; make an entry in tc.dat
(defun c:logout () (load "log") (c:logout)) ; make an entry in tc.dat
(defun c:lli () (load "nlist") (c:lli)) ; List nested entities
(defun c:ltcp () (load "livetext tools.lsp") (c:ltcp)) ;LiveText Copy
(defun c:ltd()(load "linetypescaledynamic.lsp")(c:ltd));LineType scale Dynamic
(defun c:ltl () (load "r13ltscl") (c:ltl));lengthen ltscale factor of selected objects
(defun c:lts () (load "r13ltscl") (c:lts));shorten ltscale factor of selected objects
(defun c:lumberlayers()(load "lumber")(c:lumberlayers));set layers for lumber routines
(defun c:mate()(load "attrib")(c:mate));Multiple attribute edit
Note that each entry here loads a file then runs the routine. Demand loading in this way minimizes drawing load time while maximizing routine availability.
The second section of code in my AcadDoc.lsp looks for a lisp file with the users login name and loads that file if found. this allows each individual user to create their own customizations and also allows me to build quick routines for the users on an individual basis for specific tasks.
I do not specify a path to any of my lisp routines but rather add their path to the support search path.