Skip to Content
AutoCAD® 2008 and AutoCAD LT® 2008 Bible
book

AutoCAD® 2008 and AutoCAD LT® 2008 Bible

by Ellen Finkelstein
July 2007
Beginner
1326 pages
34h 47m
English
Wiley
Content preview from AutoCAD® 2008 and AutoCAD LT® 2008 Bible

Chapter 35. Exploring AutoLISP Further

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.

Note

AutoCAD LT does not support AutoLISP. This entire chapter is for AutoCAD only.

Creating Variables

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 radius.

(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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

AutoCAD® 2009 & AutoCAD LT® 2009 Bible

AutoCAD® 2009 & AutoCAD LT® 2009 Bible

Ellen Finkelstein

Publisher Resources

ISBN: 9780470120491Purchase book