Autolisp Programming Notes PDF
Autolisp Programming Notes PDF
Autolisp Programming Notes PDF
One of the AutoCADs greatest assets is its adaptability. You can control just about every aspect
of AutoCADs operations, from appearance of its drawing editor to its variety of menus.Key
element of this adaptability is AutoCADs built-in programming language–autolisp. With
autolisp you can virtually write your own commands and redefine others.
What Is AutoLISP?
Autolisp is part of LISP programming. LISP programming is used in artificial intelligence
programming. Meaning of LISP is List Processing.Autolisp program can be written on any editor
like notepad,wordpad,Norton,visual lisp editor,etc.
7.OBJECT NAMES: Elements defined in AutoCAD e.g. line , rectangle , circle , polygon
1. + : Addition 4. / :Division
Syntax: (/ 2 5 )
Syntax: (+ 2 5 6)
5. 1+ : Returns value increased by 1
2.- : Subtraction Syntax: (1+ 3)- returns 4
Syntax: (* 2 5 )
7.cosine: returns cosine of no. in radians 10.sqrt: returns square root of number
(defun c:result()
(setq a(getreal"\n enter 1st no:")
b(getreal"\nenter 2nd no:")
c(getreal"\n enter 3rd no:")
total(+ a b c)
per(*(/ total 300.0) 100.0)
)
)
Data Type Conversions
Function : abs , atof , atoi , fix , rtos , float , itoa
(defun c:age()
(setq age(getint"\nenter your age:")
days(* age 365)
weeks(/ days 7)
)
(princ(strcat"\nyou are"(itoa days)"days old!"))
(princ(strcat"\nyou are"(itoa weeks)“weeks old!!"))
(princ)
)
LIST Filtering Functions
Functions: car, cdr, cadr, caddr, caar, cddr
2.cdr: (core data register)-Function returns list that includes everything but first item
Syntax: (cdr(1 2 3))-returns (2 3)
(defun C:RECTC()
(setq pt1 (getpoint "\nEnter a corner : ")
pt2 (getpoint "\nEnter diagonal corner : ")
pt3 (list (car pt2) (cadr pt1))
pt4 (list (car pt1) (cadr pt2))
)
(command "line" pt1 pt3 pt2 pt4 pt1 "")
)
Defining a point in polar form
Functions: entsel,ssget
Syntax: (entsel)
2.ssget: This function prompts for user to select more than one entity
The IF function first test to weather to condition is mate and then performs one
option or another depending on the out come of test .