0% found this document useful (0 votes)
22 views3 pages

Auto Lisp For Class

Uploaded by

Astha 110502
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

Auto Lisp For Class

Uploaded by

Astha 110502
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Auto Lisp

1. Rectangle

(defun c:rect ()
(setq p1 (getpoint "specify the lower left corner"))
(setq p2 (polar p1 0 10))
(setq p3 (polar p2 (/ pi 2) 5))
(setq p4 (polar p3 pi 10))

(command "line" p1 p2 p3 p4 p1 "")


)

2. Circle

(defun c:cir ()
(setq p1 (getpoint "specify the centre of circle"))

(command "circle" p1 10)


)
3. Figure 1

(defun c:fig1 ()
(setq p1 (getpoint "specify the lower left corner"))
(setq p2 (polar p1 0 10))
(setq p3 (polar p2 (/ pi 2) 5))
(setq p4 (polar p3 pi 10))
(setq p5 (polar p2 (/ pi 2) 2.5))

(command "line" p1 p2 "")


(command "arc" "c" p5 p2 p3 "")
(command "line" p3 p4 p1 "")
)

4. Figure 2

(defun c:fig2()

(setq pt (getint "specify the length of triangles"))


(setq p1 (getpoint "specify the lower left corner :"))

(setq p2 (polar p1 0 pt))


(setq p3 (polar p1 (/ pi 3) pt))

(command "line" p1 p2 p3 "c")

)
defun – Use to define new functions
setq – Assignment command. It assigns the value of one variable or constant to another variable
getpoint – specify a point
getint – specify integer value
polar – assign the location of second point with reference to previous point
princ- used to print to screen

Pausing for inputs


Inputs Command
Integer getint
Distance getdist
Real number getreal
Point getpoint
Angle getangle
Word getword
String getstring

Commands for Arithmetic operations


Addition [ + A B ]
Subtraction [ - A B ]
Multiply [ * A B ]
Division [ / A B ]
Square root [ sqrt A ]

You might also like