TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: danny on March 09, 2005, 03:29:09 PM
-
I have my ACAD search path browsing to a folder which contains .lsp files and .mns file. For some reason ACAD does not recognize the .lsp files. How can I get this to work?
-
Do get any error messages? What if you drag-n-drop from windows explorer into acad? What command are you using to load the .lsp files?
-
So this doesn't work ??
(findfile "TheHidingLispFile.lsp")
-
mark,
if I use the appload command the files will work, but I've seen it done through the search path before. The reason is because I don't want to load all lisp files in the startup or 1 by 1 when I need them.
kerry
(findfile "TheHidingLispFile.lsp")
??
-
Unusual, I've never seen it return question marks before.
Is it possible the search path is too long?
What value is returned from this?
(strlen (getvar "acadprefix"))
-
Try putting this in your .MNL file (one for each lisp you want to load).
(defun C:LISP_COMMAND () (prompt "\nLoading...") (load"path:/to/Lisp/Lisp_File") (prompt "\nloaded.")(C:LISP_COMMAND))
For example, let's say I have a routine called OT that I store in my LISP folder on my C drive. The command that runs the routine is also OT so my line in my MNL file would look like this:
(defun C:OT () (prompt "\nLoading...") (load"C:/LISP/OT") (prompt "\nloaded.")(C:OT))
don't forget to use forward slashes (/)
-
MP,
I got this
Command: (strlen(getvar"acadprefix"))
600
kerry,
Igot this
Command: (findfile"thehidinglispfile.lsp")
nil
-
i only have this single file in my startup suite which will load whatever lisps i include. works great thanks to the smart peps here :wink:
(defun danloader (/ filelst)
(setq
filelst
(list
"ADDEMUP.LSP"<<<<<<<INSERT YOUR LISPS HERE
)
)
(setvar 'cmdecho 0)
(foreach n filelst
(if (not
(findfile n)
)
(progn
(prompt (strcat "\n" n " not found"))
(princ)
); progn
;else
(load n)
); if
)
(setvar 'cmdecho 1)
(prompt "\nFiles Loaded.....")(princ)
); defun
-
That works too! :)
Mine loads them on demand.
-
MP,
I got this
Command: (strlen(getvar"acadprefix"))
600
kerry,
Igot this
Command: (findfile"thehidinglispfile.lsp")
nil
uhm, Danny, replace the "thehidinglispfile.lsp" with the name of the file you want to find.
This will not load it, just returns the address if the file is found ...
If you get the address, then we can look at loading the file ..
-
600 is reasonable, so that can be ruled out.
Now run this --
(progn
(princ (getvar "acadprefix"))
(princ)
)
What did it dump?
-
MP,
That listed what was in my search path
Command: (progn(princ(getvar"acadprefix"))(princ))
C:\Documents and Settings\derek\Application Data\Autodesk\Autodesk
Architectural Desktop 2004\R16.0\enu\SUPPORT;C:\Program Files\Autodesk
Architectural Desktop 2004\SUPPORT;C:\Program Files\Autodesk Architectural
Desktop 2004\FONTS;C:\Program Files\Autodesk Architectural Desktop
2004\HELP;C:\Program Files\Autodesk Architectural Desktop
2004\EXPRESS;C:\Program Files\Autodesk Architectural Desktop
2004\SUPPORT\COLOR;C:\DOCUMENTS AND SETTINGS\ALL USERS\APPLICATION
DATA\AUTODESK\AUTODESK ARCHITECTURAL DESKTOP
2004\R16.0\ENU\LAYERS;C:\2004CADMENU\MENU;M:\_Cad Support\AutoCAD
2004\2004dannyCAD\MENU;G:\AutoCADD misc\lisp files\UCS&Crosshairs;
kerry,
that found the path
Command: (findfile"35.lsp")
"G:\\AutoCADD misc\\lisp files\\UCS&Crosshairs\\35.lsp"
-
dan,
thanks for that, but I'm not sure how to run that? Is that a .lsp file that I put in the startup?
-
I believe the ampersand (&) in the path
G:\\AutoCADD misc\\lisp files\\UCS&Crosshairs
may be throwing the load function for a loop. I always advise our users to avoid directory and files names with embedded ampersands.
What happens if you rename the directory and modify the acadprefix variable accordingly?
-
MP,
renamed path to G:\\AutoCADD misc\\lisp files\\UCS and reloaded in the search path. Still doesn't reconize the .lsp files in that folder.
I don't understand cause I have a folder with lisp in it which works fine. If I put a new .lsp file in that folder, ACAD will not reconize it.
-
< .. >kerry,
that found the path
Command: (findfile"35.lsp")
"G:\\AutoCADD misc\\lisp files\\UCS&Crosshairs\\35.lsp"
so now how about this ?
(if (setq tmp (findfile"35.lsp") ) (load tmp) (prompt "woooooooops"))
-
Load this --
(defun *error* (msg) (vl-bt))
Now, what do these two statements output --
(load "G:\\AutoCADD misc\\lisp files\\UCS\\35.lsp")
(load "35.lsp")
-
ok. I think i got it.
if I put this in the folder
;loads lisps at start-up
;loads lisps from directory -- "G:\\AutoCADD misc\\lisp files\\UCS"
(defun s::startup()
(load "lisp here")
(load "lisp here")
(princ)
)
then ACAD will find the files. This is similar to what dan posted earlier.
-
MP, this is weird.
I have never used ampersand in folder names, so I tried it ...
Command: (findfile"test_load.lsp")
"F:\\This&That\\test_load.lsp"
Command: (if (setq tmp (findfile"test_load.lsp") ) (load tmp) (prompt "woooooooops"))
Here We are, all together again ..
nil
Command: (load "test_load.lsp")
Here We are, all together again ..
nil
Not a problem ... Weird, heh ..
WinXP Pro SP2
-
That is weird Kerry. Sorry, I cant provide concrete examples, I have a vague recollection that some dos operations ( i.e. bat files ) went wonky with ampersands. I could be mistaken tho.
-
danny yeah you just put this one lisp in your startup suite and add to it as you see fit. like i say this has worked the best for me
-
I have my ACAD search path browsing to a folder which contains .lsp files and .mns file. For some reason ACAD does not recognize the .lsp files. How can I get this to work?
Just to be clear, by your "ACAD search path", you mean the "Support File Search Path" listing in the options dialog you get by typing OP, right? Or are you talking about something else?
-
Still doesn't reconize the .lsp files in that folder. ... ACAD will not reconize it.
Okay, I'm slow, what do you mean by "recognize it"? Is it not showing up in the appload list or what?
A lisp routine has to be loaded before it will function. Just placing the lisp file in a certain directory won't load it.
If you want deman-loading look into autoload.
In you MNL or ACAD.LSP add lines similar to these:(autoload "e:/programs/ac2002/menus/csa/UTE.lsp" '("ute"))
(autoload "e:/programs/ac2002/menus/csa/PLOTTABS.lsp" '("PLOTTABS" "PLTB"))
(autoload "e:/programs/ac2002/menus/csa/lisp/xrbg.lsp" '("xrbg"))
(autoload "E:/Programs/AC2002/Menus/csa/Lisp/cld.lsp" '("cldr" "cldh"))
If I enter the command CLDR or CLDH, the last autoload line above will load lisp function "E:/Programs/AC2002/Menus/csa/Lisp/cld.lsp", if it's not already loaded. Notice that the keyboard entries match the defun names, not necessarily the function file name.
-
Still doesn't reconize the .lsp files in that folder. ... ACAD will not reconize it.
Okay, I'm slow, what do you mean by "recognize it"? Is it not showing up in the appload list or what?
A lisp routine has to be loaded before it will function. Just placing the lisp file in a certain directory won't load it.
If you want deman-loading look into autoload.
In you MNL or ACAD.LSP add lines similar to these:(autoload "e:/programs/ac2002/menus/csa/UTE.lsp" '("ute"))
(autoload "e:/programs/ac2002/menus/csa/PLOTTABS.lsp" '("PLOTTABS" "PLTB"))
(autoload "e:/programs/ac2002/menus/csa/lisp/xrbg.lsp" '("xrbg"))
(autoload "E:/Programs/AC2002/Menus/csa/Lisp/cld.lsp" '("cldr" "cldh"))
If I enter the command CLDR or CLDH, the last autoload line above will load lisp function "E:/Programs/AC2002/Menus/csa/Lisp/cld.lsp", if it's not already loaded. Notice that the keyboard entries match the defun names, not necessarily the function file name.
Same way mine works.
I've been using the method I posted since AutoCAD R9.
-
Same way mine works.
I've been using the method I posted since AutoCAD R9.
I tried something similar to yours long ago, but I noodled it up somehow. It kept getting hung in a never-ending loading loop. Before I could figure out what I had noodled up, I found autoload.
-
Well the autoload method sure is cleaner, that's for sure.
You know what they say though... if it ain't broke, hire an architect. No. Wait. 'If it ain't broke don't fix it". That's it!
And, in defense of architects who might have taken offense to my mild attempt at humor I'll offer the following quote:
"If you think good architecture is expensive, try bad architecture."
- Brian Foote and Joseph Yoder
-
More on Autoload:
http://theswamp.org/phpBB2/viewtopic.php?t=3023&highlight=autoload
http://theswamp.org/phpBB2/viewtopic.php?p=24450#24450
-
So I just loaded 2006 and set up my installer to load all my routines. I use CAB's method of loading my lisp but am getting this:
; error: no function definition: AUTOLOAD
My install uses Acad install and inno setup.
Should place drop down menu......but didn't.
I have an acad.lsp with:
(AUTOLOAD "a2c" '("a2c"))
(AUTOLOAD "abl" '("abl"))
(AUTOLOAD "acret" '("acret"))......
and in my mnl file:
(vl-load-com)
(vl-vbaload (findfile "C:/Program Files/AutoCAD Tools/create_lyrs.dvb"))
(vl-vbaload (findfile "C:/Program Files/AutoCAD Tools/acad.dvb"))
(load "C:/Program Files/AutoCAD Tools/acad.lsp")
(princ)
HMMMM???
Ron
-
ronjonp
I have seen this before, I had a program to remove a search path and i got hose and deleted the "Main Search Path"
C:\Documents and Settings\tspangle\Application Data\Autodesk\AutoCAD 2006\R16.2\enu\support
and when that happened it will give you this error. Obviuosly your will be differant unless you logon is the same as mine, in which case "I know your password" :lol:
look to see if you have a search path like this
-
Tim,
I have that path in the support file seach paths??
Ron
-
thanks CAB,
This (autoload) is sweet. I like the fact that it will only load a lisp file on demand.
-
I modified this routine sometime ago to write the autoload lines for all the lisp routines in a selected dir. The output file name is ACAD.LSP in the same dir picked. It's nice to use....especially if you have 100+ routines.
(defun c:acadlsp (/ fname dir dirlist file cntr)
(setq fname (getfiled "Select a lisp file directory" "" "lsp" 8))
(if fname
(progn
(setq dir (vl-filename-directory fname)
dirlist (vl-directory-files dir "*.lsp")
file (open (strcat dir "\\ACAD.LSP") "w")
cntr 0
)
(repeat (length dirlist)
(setq fname (vl-filename-base (nth cntr dirlist)))
(write-line
(strcase
(strcat "(AUTOLOAD \"" fname "\" '(\"" fname "\"))")
T
)
file
)
(setq cntr (1+ cntr))
)
(close file)
)
)
(princ dir)
(princ)
)
It will work with spaces in the directory.
*cleaned up code*
Ron
-
Very cool Ron. :)
-
Hmmm... Interesting topic. Quite a few ways to skin this kitty. I've been doing a few different things and just a week or so ago set up something similar to
have an acad.lsp with:
(AUTOLOAD "a2c" '("a2c"))
(AUTOLOAD "abl" '("abl"))
(AUTOLOAD "acret" '("acret"))......
except it's an acaddoc.lsp file.
A few lisps are "load" rather than "autoload" though.
I used to use the startup suite, but had periodic problems with it. Prolly something I did to screw it up though. :oops:
All our custom lisps are in one folder on the server and users s'port paths point to it. I can just add files as I create them, and they're instantly available to everyone.
-
ron,
dude...you just saved me choke time,
mahalo,
-
Cool Ron, thanks.
-
Glad to have helped :)