AutoCAD 2002 Bible

Скачать в pdf «AutoCAD 2002 Bible»


(setq name «Robin»)


«Robin»



4    4    4    4


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


4    4    4    4


You can also nest AutoLISP expressions — place one inside the other.


(setq radius (+ 2 1))


3


As explained in the previous chapter, AutoLISP evaluates LISP expressions from the innermost set of parentheses outward. AutoLISP evaluates (+ 2 1) first, and then assigns the result to the variable radius.

Step-by-Step: Using AutoLISP Variables from within AutoCAD


1.    Open a drawing using the Start from Scratch option.


2.    Type (setq radius (+ 2 1)) J. AutoLISP returns 3.


3.    Start the CIRCLE command. Specify any center point. At the Specify radius of circle or [Diameter]: prompt, type !radiusJ. AutoCAD draws a circle with a radius of 3 units.


4.    Type (setq color “green”) J. AutoLISP returns «green».


5.    Type -color J. At the Enter default object color <BYLAYER>: prompt, type !color J.


6.    Draw a circle. The circle is green because the current color is now green.


7.    Save your drawing in your AutoCAD Bible folder as ab35-1.dwg.

Working with AutoCAD Commands


Accessing AutoCAD commands from within AutoLISP is a powerful way to automate commonly used functions. By combining access to commands from AutoLISP with variables as described in the previous section, you gain a great deal of flexibility.

Скачать в pdf «AutoCAD 2002 Bible»