Author Topic: loading lisp routines  (Read 11491 times)

0 Members and 2 Guests are viewing this topic.

danny

  • Guest
loading lisp routines
« 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?

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
loading lisp routines
« Reply #1 on: March 09, 2005, 03:51:18 PM »
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?
TheSwamp.org  (serving the CAD community since 2003)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
loading lisp routines
« Reply #2 on: March 09, 2005, 03:51:34 PM »
So this doesn't work ??

(findfile "TheHidingLispFile.lsp")
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

danny

  • Guest
loading lisp routines
« Reply #3 on: March 09, 2005, 04:10:57 PM »
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
Quote
(findfile "TheHidingLispFile.lsp")

??

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
loading lisp routines
« Reply #4 on: March 09, 2005, 04:15:08 PM »
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"))
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

nivuahc

  • Guest
loading lisp routines
« Reply #5 on: March 09, 2005, 04:22:35 PM »
Try putting this in your .MNL file (one for each lisp you want to load).

Code: [Select]
(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:

Code: [Select]
(defun C:OT      () (prompt "\nLoading...") (load"C:/LISP/OT")      (prompt "\nloaded.")(C:OT))

don't forget to use forward slashes (/)

danny

  • Guest
loading lisp routines
« Reply #6 on: March 09, 2005, 04:27:10 PM »
MP,
I got this
Code: [Select]
Command: (strlen(getvar"acadprefix"))
600

kerry,
Igot this
Code: [Select]
Command: (findfile"thehidinglispfile.lsp")
nil

ELOQUINTET

  • Guest
loading lisp routines
« Reply #7 on: March 09, 2005, 04:27:21 PM »
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:

Code: [Select]
(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

nivuahc

  • Guest
loading lisp routines
« Reply #8 on: March 09, 2005, 04:29:06 PM »
That works too! :)

Mine loads them on demand.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
loading lisp routines
« Reply #9 on: March 09, 2005, 04:32:54 PM »
Quote from: danny
MP,
I got this
Code: [Select]
Command: (strlen(getvar"acadprefix"))
600

kerry,
Igot this
Code: [Select]
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 ..
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
loading lisp routines
« Reply #10 on: March 09, 2005, 04:34:49 PM »
600 is reasonable, so that can be ruled out.

Now run this --

Code: [Select]
(progn
    (princ (getvar "acadprefix"))
    (princ)
)

What did it dump?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

danny

  • Guest
loading lisp routines
« Reply #11 on: March 09, 2005, 04:48:22 PM »
MP,
That listed what was in my search path
Code: [Select]
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
Code: [Select]
Command: (findfile"35.lsp")
"G:\\AutoCADD misc\\lisp files\\UCS&Crosshairs\\35.lsp"

danny

  • Guest
loading lisp routines
« Reply #12 on: March 09, 2005, 04:50:40 PM »
dan,
thanks for that, but I'm not sure how to run that?  Is that a .lsp file that I put in the startup?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
loading lisp routines
« Reply #13 on: March 09, 2005, 04:58:41 PM »
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?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

danny

  • Guest
loading lisp routines
« Reply #14 on: March 09, 2005, 05:16:19 PM »
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

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
loading lisp routines
« Reply #15 on: March 09, 2005, 05:19:36 PM »
Quote from: danny
< .. >kerry,
that found the path
Code: [Select]
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"))
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
loading lisp routines
« Reply #16 on: March 09, 2005, 05:23:15 PM »
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")
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

danny

  • Guest
loading lisp routines
« Reply #17 on: March 09, 2005, 05:32:25 PM »
ok. I think i got it.
if I put this in the folder
Code: [Select]
;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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
loading lisp routines
« Reply #18 on: March 09, 2005, 05:55:32 PM »
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
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
loading lisp routines
« Reply #19 on: March 10, 2005, 12:57:55 AM »
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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ELOQUINTET

  • Guest
loading lisp routines
« Reply #20 on: March 10, 2005, 08:50:02 AM »
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

sinc

  • Guest
Re: loading lisp routines
« Reply #21 on: March 10, 2005, 12:13:09 PM »
Quote from: danny
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?

CADaver

  • Guest
loading lisp routines
« Reply #22 on: March 10, 2005, 12:33:24 PM »
Quote from: danny
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:
Code: [Select]
(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.

nivuahc

  • Guest
loading lisp routines
« Reply #23 on: March 10, 2005, 12:37:16 PM »
Quote from: CADaver
Quote from: danny
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:
Code: [Select]
(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.

CADaver

  • Guest
loading lisp routines
« Reply #24 on: March 10, 2005, 12:44:16 PM »
Quote from: nivuahc
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.

nivuahc

  • Guest
loading lisp routines
« Reply #25 on: March 10, 2005, 12:51:09 PM »
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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ronjonp

  • Needs a day job
  • Posts: 7527
loading lisp routines
« Reply #27 on: March 10, 2005, 02:25:31 PM »
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

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
loading lisp routines
« Reply #28 on: March 10, 2005, 02:39:39 PM »
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
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

ronjonp

  • Needs a day job
  • Posts: 7527
loading lisp routines
« Reply #29 on: March 10, 2005, 03:41:37 PM »
Tim,

I have that path in the support file seach paths??

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

danny

  • Guest
loading lisp routines
« Reply #30 on: March 10, 2005, 03:58:01 PM »
thanks CAB,
This (autoload) is sweet.  I like the fact that it will only load a lisp file on demand.

ronjonp

  • Needs a day job
  • Posts: 7527
loading lisp routines
« Reply #31 on: March 10, 2005, 04:26:05 PM »
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.


Code: [Select]
(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
« Last Edit: August 24, 2006, 10:39:12 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
loading lisp routines
« Reply #32 on: March 10, 2005, 05:55:57 PM »
Very cool Ron. :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Birdy

  • Guest
loading lisp routines
« Reply #33 on: March 10, 2005, 07:15:18 PM »
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
Quote
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.

danny

  • Guest
loading lisp routines
« Reply #34 on: March 10, 2005, 07:42:55 PM »
ron,
dude...you just saved me choke time,
mahalo,

CADaver

  • Guest
loading lisp routines
« Reply #35 on: March 10, 2005, 08:13:05 PM »
Cool Ron, thanks.

ronjonp

  • Needs a day job
  • Posts: 7527
loading lisp routines
« Reply #36 on: March 11, 2005, 10:53:37 AM »
Glad to have helped :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC