Our Friends: Leaflet Printing , Presented by: Talia Cad Software

Sign In

Subscribe

Subscribe to Daily Autocad.


Dec 05
Tuesday
AutoLISP
AutoLISP.2: Programming with Visual LISP editor.
Autocad 2002 and higher versions

 

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.1
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.

Table.1

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
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: 

Table.2

Color coding

Table.3

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
Fig.2.3. An example for a proper coding.

Source: Visual LISP help file.

Viewed 17,036 times so far... This week: 65 Today: 3 Latest: 5 July 2009, 1:06

Post Tags:

18 Responses to “ AutoLISP.2: Programming with Visual LISP editor. ”
  1. Are you planning to explain Object DCL later on?

  2. Hi Alvaro,

    Yes it may be considered despite we left the Object DCL language

  3. 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.

  4. Hi Johnny,

    Thanks your comment. Muharrem can answer your questions. Please take a few day after christmas.
    Have a nice day…

  5. How can I get the line numbers to show up? Thank you.

  6. I wanna learn AUTOLisp!!!!!!!!!!!!!

  7. what type of test editing program must be used to edit any of the customizable files for Auto CAD?

  8. 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

  9. I want to read about extracting values from a adrawing to Note Pad and then to Ex cell Sheet

  10. How can I protect my codes. How can I make it appear in human unreadable symbols like what I see in other codes

  11. 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.

  12. 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

  13. I’m using Notepad++ which can be downloaded from notepad-plus.sourceforge.net

  14. haythem sakka

    Jul 11, 2008
    Reply

    thank you very much

  15. Sir/Madam,
    After writting the vlisp codes in .lsp file.
    can you please suggest how to execute the code in order to get the results/

  16. RAJA KALIRAJAN

    Apr 11, 2009
    Reply

    hi to all,

    am working as a drafts man, i want to learn how to write lisp.
    Please send me the correct path


Post a Comment



All content and source © 2008 Daily Autocad | News Plus wordpress theme brought to you by Zidalgo.