Introduction to Visual LISP Editor Inside AutoCAD (VLISP)

By Isaac Harper, Infrastructure Industry Specialist, ATG West 

Are you still updating your AutoLisp Routines in Notepad? If so, you know why people say LISP stands for Lost In Stupid Parentheses! Because it can be nerve racking trying to make sure everything is matched up properly. So what it I told you that there is a LISP Editor inside AutoCAD that is fairly easy to use, has some basic functions that allow you to automate testing processes and debugging mistakes…. all in an editor that is COLOR CODED!

What VLISP offers:
During the development cycle of an AutoLISP application or routine, the AutoLISP user performs a number of operations that are not available within the AutoCAD software. Some of these operations—like text editing—are available with other software tools. Others, such as full AutoLISP source-level debugging, are introduced only with VLISP. In VLISP, you perform most of the necessary operations inside a single environment. This permits text editing, program debugging, and interaction with AutoCAD and other applications. There are several components if the Visual LISP IDE:

There are several components to the Visual Lisp Editor but I just want to introduce the basics of using it to look at a routine to show you how much easier it is to see how a routine looks in the VLISP (or VLIDE) command in AutoCAD.

Using Visual LISP documentation
The Visual LISP Developer’s Guide explains how to use the VLISP IDE and how to build and run AutoLISP applications. This guide also introduces the constructs of the AutoLISP language.

Starting Visual LISP

1. Start AutoCAD.

2. In the Tools menu select AutoLISP and then select Visual LISP Editor, or from the command prompt type: VLIDE or VLISP [Enter]. If it is the first time being loaded in the drawing session the Trace window may appear with info about current Visual LISP release and any errors that might be encountered when loading Visual LISP. The Visual LISP window has four areas; Menu, Toolbars, Console window, and Status bar.

 

 

 

Menu: The top of the Visual LISP window, will display the menu items, also the function of the menu item is displayed in the status bar.

Toolbars: Visual LISP has five toolbars; Debug, Edit, Find, Inspect, and Run. Depending on the window that is active, the display of the toolbars changes.

Console window: The Visual LISP Console window is contained inside the Visual LISP window. The window can be used to enter AutoLISP or Visual LISP commands. For example if you want to add two numbers, enter   (+ 2 9.5) next to the $ sign and then press the [Enter] key. Visual LISP will return & display the results in the same window.

Status bar: The bottom of the Visual LISP window, will display related information on menu items or a toolbar.

Using Visual LISP Text Editor to check an existing routine.

1. Select Open File from the File menu. The Open File to edit/view dialog will display. Then navigate to that file location, select the file and click the open button at the bottom of the dialog. The Visual LISP Text Editor window is displayed with the routine inside of it. (A sample TRI.LSP is some in the example below.)

a. Note: if you would like to see how this works when creating a new routine then do a File New and type in the follow in the dialog below. Watch the editor as you type in a Close Parentheses on how it will automatically show you where its matching Open Parentheses is by flashing to that location. Afterwards you can save the lisp routine by clicking the disk icon and giving it a name if you would like.

 

 

 

 

 

 

 

Color Coding

Visual LISP Text Editor provides color coding for files that are recognized by Visual LISP. Some of the files that it recognizes are LISP, DCL, SQL, and C language source files. When you enter text in the editor; Visual LISP automatically determines the color and assigns it to the text. The following table shows the default color scheme:

Visual LISP Text Element Color                                                     
Parentheses: Red
Built-in functions: Blue
Protected symbols: Blue
; Comments: Magenta w/ gray background
Strings: Magenta
Real numbers: Teal
Integers: Green
Unrecognized items: Black (like user variables)

 

Other Helpful Hints on matching parentheses:

While in the Text Editor pressing the CTRL + [ (open bracket) looks for the matching open parentheses, and pressing the CTRL + ] (close bracket) looks for the matching close parentheses, This will help you match up your parentheses while creating lisp routines in the Visual Lisp Text Editor.

This will allow you to use a basic editor to visually see your lisp (and other programming) files in an easy to read display. For example, if accidentally added something like an extra ( “ )Quotation mark somewhere in the file it would appear like this in Notepad vs the VLISP editor… you can see how much easier it is to find the mistake by the color coding.
Compare this to the one above…

 

 

 

Loading the routine from the editor
The next great thing you can do in the editor is load the full (or just a highlighted section) straight into AutoCAD without needing to do an APPLOAD or some other means of loading the routine to test. Just pick the appropriate button on the menu.

 

Note if you get an error message…

What the Error Prompts mean:

Error Prompts:

; error: misplaced dot on input: need zero in front of decimals; i.e. (+ 1 .25 )
; error: malformed string on input: missing matching quotes; i.e. (command “line)

; error: malformed list on input: does not make a list, i.e. adding a number to nothing (+ 2 ), or parentheses not matching to close the list function (setq a (list a b).

; error: extra right paren on input: to many close parentheses; i.e. (setq a))

; error: too few arguments: not enough info or incorrect ; i.e. (SETQ A 2 3)

; error: bad syntax: improper format of function;
i.e. (DEFUN C: BOX) “should not have space between c: and box.”

; error: bad argument type:numberp :nil or improper value of a symbol or format of

function; i.e. (use !name to find nil symbol).

 

There are other that may appear, but these are the main ones that usually happen.

Until next time, I hope this helps in viewing and understanding your LISP files a lot better.

 

Applied Technology Group is a Platinum Autodesk Business Partner. Founded in North Little Rock, Ark., in 1992 as a local computer services company, ATG has grown to become a leading design technology partner with the purpose of assisting customers in maximizing the value and adoption of advanced technologies so they can perform competitively in the AEC sector. ATG collaborates with customers across the Gulf South, Midwest and Southwest through partnerships with 3DR, Autodesk, Leica, Microsoft and Panzura. Learn more about our company at www.atgusa.com.

 

Autodesk and the Autodesk logo are registered trademarks or trademarks of Autodesk, Inc., and/or its subsidiaries and/or affiliates in the USA and/or other countries.