Learn AutoLISP for AutoCAD productivity
What is AutoLISP?
AutoLISP is a programming language designed specifically for use with the full version of AutoCAD (i.e. it does not work with AutoCAD LT). AutoLISP is one of a number of Application Programming Interfaces (APIs) built into AutoCAD but it is probably the easiest to use and therefore the most productive for the beginner. If you'd like to learn how to use AutoLISP to improve productivity, you're in the right place.
AfraLISP will help you get to grips with AutoLISP as quickly and easily as possible using some great tutorials for beginners. But the site also contains many intermediate and advanced AutoLISP tutorials to take you much further than the basics. In addition, AfraLISP provides DCL Tutorials (Dialog Control Language), Visual LISP tutorials, VBA Tutorials and AutoCAD customization tutorials in case you'd like to take your AutoLISP and AutoCAD programming to the next level.
Beginners Start Here
Popularity: 43.6 visits/day | Last visit: 23 mins ago
Popularity: 31.7 visits/day | Last visit: 33 mins ago
Popularity: 22.3 visits/day | Last visit: 36 mins ago
Popularity: 18.1 visits/day | Last visit: 42 mins ago
Popularity: 19 visits/day | Last visit: 57 mins ago
Popularity: 52.6 visits/day | Last visit: <1 minute ago
Popularity: 8.2 visits/day | Last visit: 1 hour ago
Popularity: 12.6 visits/day | Last visit: 1 hour ago
Popularity: 7.2 visits/day | Last visit: 1 hour ago
Popularity: 4.6 visits/day | Last visit: 53 mins ago
Popularity: 5.3 visits/day | Last visit: 1 hour ago
Popularity: 4.6 visits/day | Last visit: 51 mins ago
Tip of the Day
In many AutoCAD commands, AutoCAD remembers the last entry and puts that entry between angle brackets (<>). Then all you have to do is press Enter, and that value is used. You should use that technique whenever you're creating your own defaults in AutoLISP. First make sure that you haven't declared as local the variable that will hold the value. Then follow a three-step process :
- Require input from the user and assign that input to a second variable.
- Test to see if the input is nil, and if it is nil, assign a global variable to the real variable.
- Finally, assign the real variable to the global variable.
You're then ready for the next sequence.
Here's an example :
(defun c:prog1 (/ a) (if (= gv nil) (setq gv 1.0) );end if (princ "\nEnter Distance <") (princ gv) (princ "> ") (setq a (getdist)) (if (= a nil) (setq a gv) );end if (setq gv a) (princ "\nThe Distance is ") (princ a) (princ) );defun
gv is the global variable. No matter how often you run this routine while in the same drawing, it will maintain the last entry as the default. The first time through the routine, gv is tested to see if it has a value. If it doesn't, the routine assigns 1.0 as the default value.
Missed a Tip?
Did you miss yesterday's tip? Maybe you forgot to drop by or maybe you didn't visit over the weekend. If so, you can now see all the tips published during the past week.