IN THIS CHAPTER
Creating variables and functions
Working with AutoCAD commands and system variables
Working with lists
Setting conditions and creating loops
Managing drawing objects
Getting input from the user
AutoLISP offers many features that enable you to create sophisticated programs. These include variables, functions, and conditional structures. You can use these features to easily work with drawing coordinates. You can retrieve information about drawing objects and then modify them. As a result, getting input from the user makes your programs more interactive.
AutoCAD LT does not support AutoLISP. This entire chapter is for AutoCAD only.
You can't do anything very useful in programming without using variables. A variable is a symbolic name that a program operates on. An important part of the usefulness of variables is that you can assign values to them. You use the SETQ function to name and assign a value to a variable.
The following example sets the value of
3 to a variable named
(setq radius 3) 3
You can try this example out in Visual LISP in the Console window. If you want to use this variable on the AutoCAD command line, precede it with an exclamation point (
!). For example:
Command: !radius 3
The exclamation point before a variable evaluates the value that is stored in the variable and returns it to the command line. When you use a variable in the Console window that you've already set, you don't need the exclamation ...