2 Attachment(s)
How autoload subroutines code
Goodnight. I would like to know how to load subroutines that I have in a directory, so that they only load when executing their command. The initial code is the following:
[COLOR=#666666][FONT=Artifakt];loads all needed subroutines
Code:
(vl-load-com)
(if (findfile ".\\Subrutinas\\LeeMac")
(mapcar '(lambda (x)
(if (wcmatch (strcase x) "*.LSP")
(load
(strcat (findfile ".\\Subrutinas\\LeeMac") "\\" x)
) ;_load
) ;_ if
) ;_ lambda
(vl-directory-files
(findfile ".\\Subrutinas\\LeeMac")
) ;_ vl-directory-files
) ;_ mapcar
) ;_ if
I tried to change "load" for "autoload", but it does not work. Ihttp://forums.augi.com/attachment.ph...d=107214&stc=1http://forums.augi.com/attachment.ph...d=107215&stc=1n leemac folder y have three files .lsp.
StrikethroughV1-1.lsp define "strike", "strike2", "strike3", "under", "under2", "overunder2"
cajaenvolvente(minboundingbox).lsp load minboundingbox.lsp.
Re: How autoload subroutines code
Quote:
Originally Posted by
marco_antonio-77339780
Goodnight. I would like to know how to load subroutines that I have in a directory, so that they only load when executing their command. The initial code is the following:
You need to Wrap Code tags around any code you post so it will display correctly on the page like your attached image. That makes it easy for us to read, test, and modify for you if needed.
Clicking the [Go Advanced] button at the bottom puts a toolbar at the top and the # icon in that toolbar places code tags around selected text for you or simply paste your code inside.
That looks like a lot of work just to load a lisp file. First I'd put the folders where you keep your code in the Support and Trusted paths, then add
Code:
(load "LM:boundingbox")
as the second line of code assuming that's the name of the lisp file it's defined in.
Do you really keep all your customization on a flash drive (USB-01)?
Re: How autoload subroutines code
Code:
;loads all needed subroutines
(vl-load-com)
(if (findfile ".\\Subrutinas\\LeeMac")
(mapcar '(lambda (x)
(if (wcmatch (strcase x) "*.LSP")
(load
(strcat (findfile ".\\Subrutinas\\LeeMac") "\\" x)
) ;_load
) ;_ if
) ;_ lambda
(vl-directory-files
(findfile ".\\Subrutinas\\LeeMac")
) ;_ vl-directory-files
) ;_ mapcar
) ;_ if
- - - Updated - - -
Yes, I work in this way because I always work on many different pc's.
Re: How autoload subroutines code
As Tom mentioned, it's best to have your lisp routines in a "support path" and in a "trusted path", preferably outside your AutoCAD support files, like C:\MYLISPS
As well as an acaddoc.lsp (a file you create) which sets variables and loads routines, as well as ones loading when invoked by their commands.
Maybe you can add your jump drive\folders to those paths when you start working on each machine, not sure how it works when you unplug it though?
Sample of a basic "acaddoc.lsp"
Code:
(defun-q MYSTARTUP ()
(SETVAR "OSMODE" 703) ;;variables set when opening each drawing
(SETVAR "REGENMODE" 1)
(SETVAR "GRIDMODE" 0)
(SETVAR "SNAPMODE" 0)
(SETVAR "LIMCHECK" 0) ;; and so on
(PRINC)
(LOAD "FAVORITE LISP") ;; loads lisp routines every time (need to be in support and trusted paths)
(LOAD "ANOTHER FAVORITE LISP")
;;LISP ROUTINES INVOKED BY THIER COMMANDS
(AUTOLOAD "STL" '("STL")) ;;;STEEL SHAPES, COMMAND: STL
(AUTOLOAD "WELD" '("WLD")) ;;;WELD SYMBOLS, COMMAND WLD
(setq S::STARTUP (append S::STARTUP MYSTARTUP))
Re: How autoload subroutines code
Re: How autoload subroutines code
Quote:
Originally Posted by
Tom Beauford
Good info Tom! thanks
3 Attachment(s)
Re: How autoload subroutines code
Hello, according to what I understand now I have my lisp in C:\MYLISP (see jpg's). I have written autoload code for my lisp in the same directory that "ACADDOC.LSP". I would like change the load function of my subroutines (at the beginning of all the code of ACADDOC.LSP) by a autoload function that load my subroutines only if I call his command.
In LeeMAC folder I have three lisps: cajaenvolvente(minboundingbox).lsp, minboundingbox.lsp, StrikethroughV1-1.lsp.
cajaenvolvente(minboundingbox).lsp call to LM:minboundingbox (in minboundingbox.lsp).
StrikethroughV1-1.lsp call to "STRIKE", "STRIKE2", "STRIKE3", "UNDER", "UNDER2", "OVERUNDER2"
1 Attachment(s)
Re: How autoload subroutines code
Quote:
Originally Posted by
marco_antonio-77339780
Hello, according to what I understand now I have my lisp in C:\MYLISP (see jpg's). I have written autoload code for my lisp in the same directory that "ACADDOC.LSP". I would like change the load function of my subroutines (at the beginning of all the code of ACADDOC.LSP) by a autoload function that load my subroutines only if I call his command.
In LeeMAC folder I have three lisps: cajaenvolvente(minboundingbox).lsp, minboundingbox.lsp, StrikethroughV1-1.lsp.
cajaenvolvente(minboundingbox).lsp call to LM:minboundingbox (in minboundingbox.lsp).
StrikethroughV1-1.lsp call to "STRIKE", "STRIKE2", "STRIKE3", "UNDER", "UNDER2", "OVERUNDER2"
I don't know anything about the lisp routines you're using, or what the loading code you have is doing, (is that working for you?).
I am confused about this:
Quote:
cajaenvolvente(minboundingbox).lsp call to LM:minboundingbox (in minboundingbox.lsp).
How is one lisp routine calling out the other? Is there a command
But, to use multiple commands to "AUTOLOAD" a routine (your bottom example) would look like this:
Code:
(AUTOLOAD "StrikethroughV1-1" '("STRIKE" "STRIKE2" "STRIKE3" "UNDER2" "OVERUNDER2"))
Assuming this and all supporting files are in your file support and trusted paths: