
AutoLISP Pt 3 - Autoloading Your LISP Library
In this tutorial, we dive deep into the process of autoloading Lisp routines, streamlining your AutoCAD experience.
AUTOCADAUTOLISP

My post content

Welcome back to the third installment of our AutoLISP series! In this tutorial, we dive deep into the process of autoloading Lisp routines, streamlining your Autocad experience. If you’ve been following along, you’re in for a treat as we build upon the knowledge gained in the previous videos. For the first time we explore creating and using variables, getting environment information, combining strings, and the IF statement.
Want to learn more about AutoCAD? Check out our AutoCAD class options!
Below you will find code samples that were shown in the video.
To load an external LISP routine
(load “C:PathToFile.lsp”)
To set a variable to a String
(setq VARIABLENAME “This is a string”)
To combine two strings into one
(strcat “This is a ” “string”)
To get the name of the user and set it to a variable
(setq USER (getenv “username”))
To output data to the AutoCAD command line
(prompt “nHello World”)
AutoLISP IF statement format
(if (THING TO TEST) (TRUE? DO THIS) (FALSE? DO THIS)*)
* The else statement (IF NOT DO THIS) is optional
I tend to write if statements like this so it’s more clear when I read it a year later
(if (THING TO TEST)
(TRUE? DO THIS)
(FALSE? DO THIS)*
)
Example from the video:
(if (setq IFEXISTS (findfile USERFILENAME))
(load USERFILENAME)
(prompt (strcat “nNo User File Located for user ” USER))
)
