Tutorial: Garden Path (Visual LISP IDE)
- The
Visual LISP® environment
is introduced. ActiveX®
andReactor functions of AutoLISP
are demonstrated, as well as several other extensions to the AutoLISP language provided with Visual LISP.
There are two possible executino contexts for this tutorial:
- The application may be run as interpreted LISP in piecemeal files and/ or functions that are loaded into a single document.
- Or, the program code can be compiled into a
VLX
application, denoted by a *.vlx executable. AVLX
operates from a self-contained namespace that can interact with the application-loading document.
Lesson 1: Designing and Beginning the Program(Visual LISP IDE)
Defining Overall Program Goals
Task
- Given a start point, an endpoint, and a width, draw a rectilinear boundary. The boundary can be at any 2D orientation. There should be no limit on how large or small it can be.
- Prompt the user for tile size and tile spacing values. The tiles are simple circles and will fill the boundary but must not overlap or cross the boundary.
- Place the tiles in alternating rows.
Example Location can be found in:
C:\Program Files\Autodesk\AutoCAD 2022\Tutorial\VisualLISP
Getting Started With Visual LISP
First, it helps to demonstrate what can happen when Visual LISP is waiting for contorl to return from AutoCAD.
1 | ;;; Function C:GPath is the main program function and defines the |
defun
: declare the funcationC:GPath
: Command, and the name isGPath
gp:getPointInput
andgetDialogInput
: These function names are prefixed withgp:
to indicate they are specific to the graden path applcation. This is not a requiremnet- The final
princ
without a string argument forces the program to exit quietly.
Filling the Gaps in the program
- pg:getPointInput
- pg:getUserInput
- gp:drawOutline
1 | ;;; Function gp:getPointInput will get path location and size |
- The letter
T
is the symbol for “true” in AutoLISP - The way
gpmain.lsp
is structured, each input function it calls must return a value other thannil
(no value) for the program to proceed to the next step.
An AutoLISP function will, by default, return the value of the last expression evaluated within it. In the stubbed-out functions, the only expression is a call to the alert function. But alert always returns nil. If this is left as the last expression in gp:getPointInput, it will always return nil, and you will never pass through the if to the gp:getDialogInput function.
For a similar reason, the end of the gp:DrawOutline function returns a quoted symbol (‘SomeEname) as a placeholder. A quoted symbol is a LISP construct that is not evaluated. (If you are curious about how the LISP language works, there are a number of good books available, mentioned at the end of this tutorial.)