Introduction to AutoLISP: My first AutoLISP program…
Print This Post
![]() |
Author | Orhan Toker |
| Profession | Architect M.Sc. | |
| Autodesk Authorized Consultant | ||
| Database Specialist | ||
What is AutoLISP?
AutoLISP is a version of LISP (List Processor) programming language. It is a modified version made by AutoDESK by implementing special functions for AutoCAD. Besides standard LISP functions, it is strengthened by implementation of functions which can deal with the complicated AutoCAD operations. LISP is a programming language with strong list functions and is developed for artificial intelligence studies, and it requires an editor. AutoLISP editor comes embedded within AutoCAD.
AutoLISP language, which is used for customization of AutoCAD from AutoCAD 2.0 version until now, was enough to make professional AutoCAD extensions at the beginning. However, new developed graphical interfaces and C++ programming founded with ObjectARX made AutoLISP more like a scripting language.
In spite of these developments, AutoLISP is still a very advanced scripting language that can manage AutoCAD entities, databases and commands. With its editor, embedded in AutoCAD, it is an ideal language for you inter office automations.
A simple LISP program is:
(defun myFirstFunction()
(princ “Hello World”)
(princ)
)
As you can see, each LISP function starts with paranthesis and end with one. LISP language is also known as language of “lost paranthesis”. If you don’t close any of the paranthesis you open, you definitely get an error message when you run the file you have written. Thanks to the Visual LISP editor, came with AutoCAD 2000®, now degugging can be made just like modern IDEs. As the subject arised, let’s see what this Visual LISP editor is. Visual LISP editor is the window opens up when we write VLISP command in the AutoCAD command line (Fig.1)
- Code window
- Load program into Autocad
- VisualLISP Console window
My first LISP program
Let’s write our first program. We need to open a new file but you know how to do it. Open a new file and write the code as seen in Fig.1 and save as first.lsp. There you go; you have created your first AutoLISP program.

Fig.1. Your first AutoLISP program.
In order to run this program, first you have to load it. Press button numbered with 2 (Load Active Edit Window). If you have written the code correctly you will get the message as seen in Fig.2.

Fig.2. If the code is correct, this is the message you will get from the console.
In order to run the program, it will be enough to write (myFirstfunction) from the AutoCAD command line (Fig.3)

Fig.3. Here it is, our first AutoLISP program worked.
In this lesson, a brief introduction to AutoLISP was given, and we learned VisualLISP editor in general. Now, we are ready to learn AutoLISP. See you in next lesson.
Bu yazinin Turkce’sini okumak icin basiniz…
Similar Posts
Rate this article:



(3 votes, average: 3.67 out of 5)
December 2nd, 2006 00:22
thx man, this is most useful stuff that i’ve ever read
December 2nd, 2006 10:40
Your welcome Roki,
This is the first article of my AutoLISP lessons. Keep fallowing.
December 8th, 2006 17:02
is it possible to make 2d programme in autolisp?
December 8th, 2006 23:10
very good.
macahala, ecuador sud america.
ok.
December 9th, 2006 11:37
Hello Manish,
I couldn’t understand what did you mean with 2d programme?
January 5th, 2007 16:40
Orhan Bey bilgilerinizi paylaştığınız için teşekkürler
January 9th, 2007 05:01
Manish,
Do you mean 2d drawing with the help of AutoLisp?
then yes. I would say any thing you could do from the AutoCAD screen can be scripted in the AutoLisp.
January 31st, 2007 15:11
Is there a plot command in which i can define the area to be plotted? And can i make this in AutoLISP? I only need to know wether it is possible or not. I want to find out how myself. Thanks in advance.
June 27th, 2007 16:18
I work in AutoCAD designing . I would like to know how to access each/every single entity in a drawing
- Aniket (India)
October 27th, 2007 01:10
Intruder5
Thanks for the intro to LISP, but I could not get it to work? Also looks like you are using two names for the Lisp program, myFirstFunction and myFirstLisp in Fig 2. I used just one name, but it still won’t work. What am I doing wrong?
October 30th, 2007 12:42
hello
i m new at Daily Auto CAD
i did this exercise but here is an error.when i did step 2 in Example was in VISUAL LISP CONSOLE give a message “” but in my Visual Lisp give a message “” loading…”>” now please tell me how i can make a lisp and how i will done it ?
thanx
take care
October 30th, 2007 15:30
i’m afraid you forgot one right paranthesis
November 5th, 2007 20:35
I tried it again, this time it worked! But you have an error. The defun name must match the name of the Lisp file or it won’t work. You use defun myFirstFunction but then name the file myFirstLisp, when I do that it won’t work. I have to name the file myFirstFunction to work.
It did not work the first time because I did not use paranthesis at the command line - (myFirstfFunction)
Thanks
Intruder5
January 20th, 2008 18:07
UR HELPFUL SIR!!
February 14th, 2008 10:26
Hi, I am new to this site and your tips seems very helpful and easy to understand. Very Surprizing I have learn a lot in just 2 days of browsing your site! You are a good teacher! Thank you!
February 15th, 2008 06:55
Thanks
April 21st, 2008 12:00
Very good description …Thanks a lot…
July 11th, 2008 10:48
a very nice description. thank you.
July 16th, 2008 13:52
My name Dileep
Iam a one Draughtsman
Sir ,
who can i make autolisp yoy have any vedio files
August 14th, 2008 23:37
Hello,
I have an AutoCAD 2004 – 2009 question to you, or anyone who could solve a little setting problem what AutoCAD 2009 misses.
If you would give me a valid email address I’d like to forward to you my question to you.
The reason I’m asking that, is because from work I use OutLook for e-mailing purposes, and is the only way to be able to insert two screenshots to see what I want to ask.
REspectfully,
Alexandru Kaláth
AutoCAD Designer I
Here’s the place of our logos, which did not come trough …
ASKalath@isopowerlynx.com
Phone 678-746-5151
Fax 770-664-6302
September 26th, 2008 16:14
hi..please tell me how can i give different color in a 3-d drawing by autolisp program..i need the function name and body of that function..please help me..
October 7th, 2008 18:40
Dear sir
Highway Horizontal alignment contains straights and interconnected with arcs.
After done the alignment pline, i would like to get the each segment of straight and arc portions start and end co-ordinates and arc radius in a one text file.
Like…..
X=…….,Y=…………,
X=…….,Y=…………,
X=………,Y=………….,R=…….,
X=…….,Y=…………,
Where R=Radius of Curve.
can you please write me the LISP file for to get the data above mentioned.
NvkRao
October 8th, 2008 09:34
Hello NVK,
I can try to write a lisp for your case. Please allow me a few weeks. (I’m too busy sorry)