AutoLISP.2: Programming with Visual LISP editor.
Print This Post
![]() |
Author | Orhan Toker |
| Profession | Architect M.Sc. | |
| Autodesk Authorized Consultant | ||
| Database Specialist | ||
Get organized…
Whichever programming language you are using, if you would like to develop programs in a serious manner, you have to be organized. If you want to develop an AutoLISP program with VLISP, you have to go through the stages specified below.
• Determine what your program will do and plan how you will approach to these processes.
• Design your program
• Write code
• Have the code readable and clear
• Check for errors
• Test the program and make debugging
During this lesson, we will learn main aspects of programming with AutoLISP in VLISP environment. Purpose of this lesson is to learn about the VLISP programming environment and standardize our programming practice according to this environment. Let’s get familiar with the console.

Fig.2.1 Visual LISP Console
While you are developing AutoLISP programs, VLISP console is what you will use most. You can write the functions that you want to try or results that you want to see on the right side of the bracket _$. This window has the same functionality with immediate window of Visual Studio. VLISP will keep everything that has happened during your programming practice. So, you can look back and make analysis whenever you want.
Console window is similar to AutoCAD’s command window. Although these two windows are similar to each other, you cannot use the same commands in both windows every time. For example, although it is enough to see what value is assigned to variable a, by writing a inside the VLISP console, you should write !a inside the AutoCAD console in order to learn the value of a. You can manage the below specified processes inside the console window:
• In order to continue a LISP code; if you press CTRL+ENTER together, then you can continue writing your code without running it.
• It is enough to press ENTER to run the code.
• If you select a field and press ENTER, then only the code you have selected is run.
Another difference between the AutoCAD command window and the console window is the use of SPACE button. While SPACE is used for confirmation of the command entered, it is used for SPACE character in console window.
Console window for more than one drawing
No matter how many number of drawings you open in AutoCAD, there is only one console window. You can see the commands that belong to the active drawing in the console window. Or similarly, if you enter a command which will effect AutoCAD, than the command works in the drawing which is currently active. Console window includes the history and files, which belong to the active drawing.
Using console short-cuts
The most frequently used commands that you need while working inside the console menu is placed into a short-cut menu which is activated by a right click of your mouse.

Keeping console window log
For the possible analysis you might want to make in the future, you should keep a log file that belongs to the activities of console window. In order to do this, right click with your mouse at any location inside the console window and choose “Toggle Console Log” from the menu. Locate the log file and enter its name. After this, all of the contents and activities of your console will be saved into this file.
Using the text editor

Fig.2.2. VLISP Text Editor
If you only want to try a few LISP commands console is enough. However, if you want to write a program and keep it, then load it into your drawing and run it, then you need the text editor. Text editor is a main component of VLISP, and it is very easy to use for those who are familiar with Windows programs.
VLISP Text Editor is equipped with features like finding parenthesis, coloring the syntax and automatically perceiving the keyboards, which eases programming. In order to open a new file in text editor, File/New File… is enough. Rules of writing are the same as the other editor programs. Similar to console window, there is also a right click menu in the text editor. Contents of the menu which is opened by right clicking is:

Color coding

To get help while writing code, press F1 while the cursor is at the end of the function, for which you want to receive help.
Write your code understandable
It is very important to provide the re-readability of your code. For this reason you should write your code readable. You can adjust your text format from Tools > Environment Options > Visual LISP Format Options menu. An understandable LISP code is like it is seen below in Fig. 2.3.

Fig.2.3. An example for a proper coding.
Source: Visual LISP help file.
Similar Posts
Rate this article:




December 11th, 2006 14:02
Are you planning to explain Object DCL later on?
December 11th, 2006 14:08
Hi Alvaro,
Yes it may be considered despite we left the Object DCL language
December 27th, 2006 18:45
I would like to know, How I can do to load a cui file menu from LISP code. However, How I can do create a cui file menu easily, is there another tools that do it?.
Thank you for your help.
December 28th, 2006 10:09
Hi Johnny,
Thanks your comment. Muharrem can answer your questions. Please take a few day after christmas.
Have a nice day…
January 3rd, 2007 22:50
How can I get the line numbers to show up? Thank you.
January 21st, 2007 13:11
I wanna learn AUTOLisp!!!!!!!!!!!!!
May 3rd, 2007 03:21
what type of test editing program must be used to edit any of the customizable files for Auto CAD?
May 3rd, 2007 08:03
Hi Anna,
You can use any kind of text editor (such as notepad) to edit autocad customizable files.
I’m using Notepad++ which you can download from http://notepad-plus.sourceforge.net/uk/site.htm.
Bye
June 15th, 2007 21:49
I want to read about extracting values from a adrawing to Note Pad and then to Ex cell Sheet
July 21st, 2007 09:54
[...] From now on, every saturday, we will post the most favorite article of the week once more. This weeks most favorite article was “AutoLISP.2: Programming with Visual LISP editor”. [...]
October 30th, 2007 03:06
How can I protect my codes. How can I make it appear in human unreadable symbols like what I see in other codes
October 30th, 2007 09:26
First you have to create a new project from Project menu of VLISP editor. Give a name to your new project and include the file that you want to protect its code.
Now you can rebuild your project as FAS (protected) file from Project menu.
November 9th, 2007 09:40
[...] our first AutoLISP application. To write the program, and execute it, you should read our “AutoLISP.2: Programming with Visual LISP editor” lesson. You can form up the code by following the steps [...]
December 13th, 2007 10:21
Hello Orhan,
I´ve seen in your example, you have line numbers in your Editor Windon of Lisp… is this a switchable option i didn’t find yet, or are these manually added for demonstration? If there was a way to turn on line numbers - or there was an other lispeditor with this capability that would be great…
thanks,
Daniel
December 14th, 2007 10:05
I’m using Notepad++ which can be downloaded from notepad-plus.sourceforge.net
July 11th, 2008 11:16
thank you very much