Autolisp – Visual lisp

Lesson 7 – Executing AutoCAD Commands through AutoLISP

Rather than have an entirely new set of drawing and editing commands, AutoLISP permits the user to tap all of AutoCAD's existing commands from within AutoLISP using the (command) function. Explanation: the (command) function (command [command_name] [argument...]) The first argument to the (command) function is always the command name. It is followed by the command’s options input in the same order they would be typed at the AutoCAD “Command:” prompt. AutoCAD commands and options are typed in as strings. DO NOT use Read More...

Lesson 6 – Assigning Values to Symbols

One of the most powerful features of AutoLISP is the ability to store a variable and then use it again later. In AutoLISP, these variables are called symbols, and they may be assigned a value using the (setq) function. Explanation: the (setq) function (setq symbol expression) The (setq) function must have two arguments, the symbol name and an expression assigned to the symbol name. Command: (setq A 12.0) A single (setq) command can set any number of variables. (setq symbol1 expression1 symbol2 expression2 symbol3 expression3 );end Read More...

Lesson 5 – AutoLISP Distinguishes among Several Data Types

The bulk of this class will concentrate on learning the functions of AutoLISP. But, each of these functions requires certain types of arguments for the AutoLISP expression to make sense. For example, a function that adds two numbers together would require that its arguments be numbers. We need to be able to distinguish among five different data types: integers, reals, strings, lists, and symbols. We will learn about additional data types when we discuss AutoCAD entities and selection sets in Read More...

Lesson 4 – Every List is Evaluated in the Same Specific Manner

AutoLISP assumes that a list is an expression that needs to be evaluated. The function must be the first element in a list and its arguments must immediately follow it. A generalized AutoLISP function would look this way: AutoLISP evaluates the expression depending on the function definition and the explicit arguments that are designated. Some functions have required arguments and some have both required and optional arguments. In this book we will designate optional arguments in brackets, [optional argument]. Read More...

Lesson 3 – AutoLISP Evaluates every Expression

The LISP part of AutoLISP stands for list processing, which describes what happens when you run a routine: AutoLISP processes lists or, as we say here, evaluates expressions. If you type in an AutoLISP expression at the Command line it will return the results of the processed list. Command: (+ 18 6) 24  Expressionresults Each AutoLISP expression is enclosed in parentheses. Expressions are made up of a function followed by arguments. The function is analogous to the “verb” or action Read More...

Lesson 2 – AutoCAD and AutoLISP are Two Separate Programs

Though AutoLISP is an inherent part of AutoCAD, it is in fact an entirely separate program with different executable files, its own set of commands and syntax. AutoLISP expressions, however, can be typed in directly at the AutoCAD Command: prompt, and hence there needs to be a means of differentiating AutoLISP expressions from AutoCAD expressions. To initiate an AutoLISP expression, it must begin with either an open parenthesis “(” or an exclamation point “!”. When AutoCAD sees an expression that Read More...

Lesson 1 – why AutoLISP?

Learning AutoLISP is radically different from learning AutoCAD. AutoLISP is a programming language with its own commands, its own structure, and its own syntax. However, with a knowledge of AutoLISP, AutoCAD operators can amplify their powers with AutoCAD. AutoLISP puts new tools at your fingertips: Mathematical calculations Creating variables to hold values Reading and changing AutoCAD system variables Creating reusable functions Accessing and changing entity properties Accessing drawing file properties Reading and writing ASCII files But why AutoLISP? Why not Read More...
Show Buttons
Hide Buttons
SUBSCRIBE TO OUR NEWSLETTER

It's FREE!

Sign up and receive an email every time a new tutorial is published