Getting started with programming:Let’s talk about some important functions to start with:
Setq: can stores values (integer, decimal, string and lists) to a variable.
Example: (setq P “I love India")
(setq P (list 1 2 3))
defun: It defines a user function.
(defun C:TEST1 ()
(alert “hallo world"))
In this example TEST1 could be used as a AutoCAD command and then “hallo world" statement will pop up in screen.
command: by using command function we can use AutoCAD commands in lisp programming.
(setq pt1 '(1 1) pt2 '(1 5))
(command "line" pt1 pt2 "")
In this example we can draw a line between point 1 1 and 1 5
some basic output functions of autolisp: any of the functions like promt ,princ,prin1 print will print in command window. See the example below:
(setq str "I love my india")
How to run autolisp program: Autolisp program can be loaded to auto cad by the following three ways:
• By directly typing the program statements to AutoCAD command window
• By typing the program statement to a separate notepad or WordPad and save it with a .lsp extension and then load it by following path
• By typing and run the program through visual lisp window.
The discussions I had so far is good to start autolisp programming and by following these one will be able to understand and learn the advanced topics. One can further refer my other articles of this series as well.