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 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
- Start AutoCAD.
- 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
- Select Open File from the File menu. The Open File to edit/view dialog will display.
- 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 shown in the example below).
- 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.
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 also 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 I 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.
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: 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: too 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 others that may appear, but these are the main ones that usually happen. We 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.
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.