Jump to content
dnovember99

lisp loader

Recommended Posts

dnovember99

i have been racking my brain trying to figure this out. i am sure that this is something that is very simple but being so new to the lisp world i am struggling.

 

i am looking to have one master lisp that will load all the lisp routines that i have. not sure if this would be the best way to do it, or if i should just visit the "options" and add the location of these to the support path that way it is loaded always.

 

i read a little able acaddoc.lsp but being so new i am just losing myself even more with that. can anyone provide a little direction?

 

thank you

Share this post


Link to post
Share on other sites
PDuMont

See LeeMac's ACADDOC Creator: http://www.lee-mac.com/acaddoccreator.html

 

In your acaddoc.lsp file, add

(load "yourfilename.lsp)

the name of the file from LeeMac's lisp routine.

 

All files must be in your support path.

 

When you open a new drawing, the .lsp file will only load when you type the command for it.

Share this post


Link to post
Share on other sites
dnovember99
See LeeMac's ACADDOC Creator: http://www.lee-mac.com/acaddoccreator.html

 

In your acaddoc.lsp file, add

(load "yourfilename.lsp)

the name of the file from LeeMac's lisp routine.

 

All files must be in your support path.

 

When you open a new drawing, the .lsp file will only load when you type the command for it.

 

thank you for this info. lee mac has so much stuff that i tend to get lost on his site. another question is, where i work they do not like us saving things like this to the server and/or the desktop (they go thru and wipe out stuff like this at least once a week)

 

would i be able to save it all to a thumb drive and then just path that? and of course if that is something that does work then it would only load if that thumb drive is in the computer. just a thought

Share this post


Link to post
Share on other sites
PDuMont

Thumb drive should work I think, but yes, it would error out if not connected.

I work from C:\users\public\documents\"my stuff here" on my machine, do they monitor that since it is a default location?

Share this post


Link to post
Share on other sites
dnovember99

i dont even have that path! :shock: but that gave me an idea that i will just keep my back up's (original files) on the thumb drive and then path those over to somewhere on my U: drive (that is what they gave us.)

 

 

i will have to go take a look at the acaddoc.lsp from lee mac. thank you again

Share this post


Link to post
Share on other sites
PDuMont

You're welcome.

 

My original reply was hastily typed, let me know if you need more info.

 

Good luck!

Share this post


Link to post
Share on other sites
dnovember99

i was quickly looking at the acaddoc.lsp file and it is of course well written, but so good that i am struggling to understand where to add my stuff at. i have a file that i got approved to add a few things of my own that work for me but they restrict editing.

 

this is what they have:

 

(defun c:K ()
 (setvar "POLARMODE" 2)
 (setvar "osmode" 551)
 (setvar "POLARANG" (angtof "15"))
)
;;when you type K, it resets your osnaps to your custom setting

;;Custom Routines

(defun c:c0 () (command "_copybase" "0,0") )
(defun c:v0 () (command "_pasteclip" "0,0") )
(defun c:ZZ () (command "layfrz") )

(load "_RC-CLOUDS")
(defun c:KL () (load "_KL") (C:KL))
;;DRAW BACKWARDS 3-POINT LEADER
(defun c:T2MT () (load "T2MT-MT2T") (C:T2MT))
;;TEXT TO MTEXT
(defun c:VB () (load "_VB") (C:VB))
;;VIEWPORT BOX IN MODELSPACE
(defun c:XRR () (load "XRR") (C:XRR))
;;XREF RELOAD
(defun c:XRV () (load "XRV") (C:XRV))
;;XREF RELOAD WITH VISRETAIN
(defun c:XRU () (load "XRU") (C:XRU))
;;XREF DETACH
(defun c:explodable () (load "explodable") (C:explodable))
;;explodable
(defun c:cleanbase () (load "cleanbase") (C:cleanbase))
;;Clean base drawing
(defun c:cleantitle () (load "cleantitle") (C:cleantitle))
;;Clean title drawing

(Defun c:ERD () (load "_ERD") (c:ERD))
(Defun c:ERH () (load "_ERD") (c:ERH))
(Defun c:ERT () (load "_ERD") (c:ERT))

(Defun C:QS () (command ".qsave") (princ))
(defun c:read ()
 (defun c:qs () (alert "NO! NO! NO! NO! NO! NO!"))
)


(defun c:Dave()
 (load "_0Dave.lsp")
 (alert "Dave - list of commands \nK - Your ACAD Defaults \nQS - Quick Save \nERH Erase Hatch \nMA Match Properties\nREAD - removes Quick Save command \nKL - Draw backwards three point leader \nCleantitle - Clean title drawing \nCleanBase - Clean base drawing\nRCC - Rev Cloud Sketch \nRCB - Rev Cloud Block")
)

(print "Dave Lisp Loaded Successfully!")
(princ)

(defun c:MA () (COMMAND "MATCHPROP") )
;;XREF DETACH

 

i am wondering if i can just copy this layout and ad my own things. and just give

 

(defun c:Dave() (load "_0Dave.lsp")

 

or would i even need to have the (defun c:dave() in there? could i change that to

 

(;;defun c:Dave()

 

just to have this show up as a note so if i am looking at it i know the reason why i have this and if i want to be able to delete it or not? just a few thoughts.

Share this post


Link to post
Share on other sites
dnovember99

ok so with this would i then path it or would i add this to my start up suit?

 

will this allow me to lets say open up a drawing and just type "invert" one of my lisp routines that someone here helped me write (well after all said and done they wrote it) and it will work normally? and with the said lisp that i have i also have a .dcl and a block that i have to load into this.

 

i am fine making a change if it is needed. either way works for me.

Share this post


Link to post
Share on other sites
PDuMont

OK, I am a bit confused as to what you are doing.

 

Here's is how I'm set up:

 

Folder structure = "AutoCAD Lisp\Lisp 1\Lisp"

 

"Lisp 1" folder has my accaddoc.lsp file (autocad will only use 1 of these)

Inside this lisp file is this:

(vl-load-com)
(acad-push-dbmod)
(load "PDuMont-Commands")
(load "PDuMont-Lisp")
(load "LayerAuto.lsp")
(load "AutoSave.lsp")
(acad-pop-dbmod)

 

"Lisp" folder has my pile of lisp routines, dcl files, sld files etc.

Run LeeMac's autoloader lisp on the folder with your pile of routines

and you should end up with a file that looks like this:

(autoload "C:/Users/Public/Documents/AutoCAD Lisp/lisp/ArrowArcV1-2.lsp" '("AARC"))
(autoload "C:/Users/Public/Documents/AutoCAD Lisp/lisp/AddObjectsToBlockV1-1.lsp" '("A2" "RF"))
(autoload "C:/Users/Public/Documents/AutoCAD Lisp/lisp/AllLayerOff.lsp" '("ALO"))
;(autoload "C:/Users/Public/Documents/AutoCAD Lisp/lisp/AnonymousBlock-Rename.lsp" '("UNANONALL" "UNANON"))
(autoload "C:/Users/Public/Documents/AutoCAD Lisp/lisp/Arc2Circle.lsp" '("A2C"))
(autoload "C:/Users/Public/Documents/AutoCAD Lisp/lisp/AreaText.lsp" '("AT"))
(autoload "C:/Users/Public/Documents/AutoCAD Lisp/lisp/Attribute-Constant-Flip2x.lsp" '("AF"))
(autoload "C:/Users/Public/Documents/AutoCAD Lisp/lisp/AutoDado.lsp" '("DD" "CD" "DD2"))
(autoload "C:/Users/Public/Documents/AutoCAD Lisp/lisp/AutoExtrude.lsp" '("LE" "RECE" "CE"))
(autoload "C:/Users/Public/Documents/AutoCAD Lisp/lisp/AutoRotate.lsp" '("3DR"))

 

This is the file pointed to in the acaddoc.lsp

(load "PDuMont-Lisp")

 

Again, all files must be in your autocad support path.

Share this post


Link to post
Share on other sites
dnovember99

ok i am going to have to sit down and look a little closer at the stuff you sent from lee mac to understand it a little better.

 

really i just want to be able to have the best route to load stuff and have it work. so either way is fine with me. that is just want i am working with now. but i will look deeper into this stuff.

 

thank you again

Share this post


Link to post
Share on other sites
BIGAL

Have you thought about going to menu's or toolbars these can be pathed to look for a USB or a drive etc. This way one you dont forgot what you called the shortcut. They are grouped to common themes my case alphabetical. Its only a text file so no smart programming required. Some of these do use a library lisp but agian if not loaded pretty simple to force a load 1st. Look at "(if (not aH:getvals"

Screen Shot 01-10-18 at 01.13 PM.jpg

Share this post


Link to post
Share on other sites
asos2000

I like this type of loading lisps

(defun c:AAA	()	(load "C:/HasanCAD/AutoCAD/Support/Lisp/AAA.LSP"		) (c:AAA	) (princ)) ; text
(defun c:BBB	()	(load "C:/HasanCAD/AutoCAD/Support/Lisp/ABB.LSP"		) (c:BBB	) (princ)) ; text
(defun c:CCC	()	(load "C:/HasanCAD/AutoCAD/Support/Lisp/CCC.LSP"		) (c:CCC	) (princ)) ; text

 

By using this way of loading the lisp will not loaded until the user call the lisp.

Share this post


Link to post
Share on other sites
dnovember99
Have you thought about going to menu's or toolbars these can be pathed to look for a USB or a drive etc. This way one you dont forgot what you called the shortcut. They are grouped to common themes my case alphabetical. Its only a text file so no smart programming required. Some of these do use a library lisp but agian if not loaded pretty simple to force a load 1st. Look at "(if (not aH:getvals"

 

 

i do kinda like that idea. now with the "(if(not aH:getvals" which section would i be looking at with this one?

Share this post


Link to post
Share on other sites
dnovember99
I like this type of loading lisps

(defun c:AAA	()	(load "C:/HasanCAD/AutoCAD/Support/Lisp/AAA.LSP"		) (c:AAA	) (princ)) ; text
(defun c:BBB	()	(load "C:/HasanCAD/AutoCAD/Support/Lisp/ABB.LSP"		) (c:BBB	) (princ)) ; text
(defun c:CCC	()	(load "C:/HasanCAD/AutoCAD/Support/Lisp/CCC.LSP"		) (c:CCC	) (princ)) ; text

 

By using this way of loading the lisp will not loaded until the user call the lisp.

 

 

 

 

i am just wanting to make sure that i am understanding this. (sorry very green) the (load "C:/HasanCAD/AutoCAD/Support/Lisp/AAA.LSP" this would be the file path of said lisp that you are wanting to add to the file?

Share this post


Link to post
Share on other sites
asos2000

subose you have a lisp called GetSlope.LSP and command to invoke the lisp is GTS

(defun c:GTS	()	(load "C:/HasanCAD/AutoCAD/Support/Lisp/GetSlope.LSP"		) (c:GTS	) (princ)) ; Get Slope at specified point

That means whenever you call the lisp, It will be loaded.

Share this post


Link to post
Share on other sites
dnovember99
subose you have a lisp called GetSlope.LSP and command to invoke the lisp is GTS

(defun c:GTS	()	(load "C:/HasanCAD/AutoCAD/Support/Lisp/GetSlope.LSP"		) (c:GTS	) (princ)) ; Get Slope at specified point

That means whenever you call the lisp, It will be loaded.

 

that make perfect sense.

 

thank you

Share this post


Link to post
Share on other sites
Steven P

I use this:

 

(defun c:appreload ()
;;Load all LISP files in a folder
;;LISP folder location:
 (setq mylispfolder "c:\\Desktop\\") ;;change this to suit

 (setq myfiles (vl-directory-files mylispfolder "*.lsp" nil)) ;;myfiles is list of files
 (setq mylistlength (length myfiles)) ;;count of number of lsp files
 (setq acount -1) ;;a counter

 (repeat mylistlength
   (setq acount (1+ acount))
   (setq FailedtoLoad (strcat (nth acount myfiles) " failed to load"))
   (load (strcat mylispfolder (nth acount myfiles)) FailedtoLoad) ;;Loads file
 )
 (princ)
)

 

This will load all the LISP files in a specified folder. Its probably not the smartest code but it works for me.

 

Note: If you are having this run at start up then don't do it from a LISP file contained in the 'mylispfolder' location since it is possible to get an endless loop when it loads / reloads that file and it runs this routine again... and again... You could modify this code to exclude a file to reload if you want.

 

 

I use this mainly when I am trying things out - far quicker to type in appreload than going through AutoCAD to load a modified LISP file

Share this post


Link to post
Share on other sites
Steven P

Writing a line for each LISP routine:

(defun c:GTS	()	(load "C:/HasanCAD/AutoCAD/Support/Lisp/GetSlope.LSP"		) (c:GTS	) (princ)) ; Get Slope at specified point

works nicely, but suppose you have many LISP routines to load? (for example, I have 1 routine to plot A3, one to plot A2 etc, and black and white, and PDF colour and black and white, landscape plot and portrait plot.. about 40 routines just for plotting, then there are all the others...). You can modify my example with this line if you can get a list of all the LISPs within all the files in a folder (Lee Macs GetSyntax can help here). Mine will load everything in a folder so add a new file in there, it will load with no other work. Its just another idea for you to consider

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×