0% found this document useful (0 votes)
11 views

Auto Lisp For Class

The document describes Auto Lisp functions for drawing basic geometric shapes like rectangles, circles, and figures. It defines functions like c:rect() to draw a rectangle by getting points for the corners and using the command "line" to connect them. Similarly, c:cir() defines a function to draw a circle by getting a center point and using the command "circle". It also shows functions like c:fig1() and c:fig2() to draw more complex figures by getting input points and using commands like "line", "arc", and "line" to construct the shapes. Key Auto Lisp concepts introduced are defun to define functions, setq for assignment, getpoint to specify points, and commands like

Uploaded by

Mohit Jani
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)
11 views

Auto Lisp For Class

The document describes Auto Lisp functions for drawing basic geometric shapes like rectangles, circles, and figures. It defines functions like c:rect() to draw a rectangle by getting points for the corners and using the command "line" to connect them. Similarly, c:cir() defines a function to draw a circle by getting a center point and using the command "circle". It also shows functions like c:fig1() and c:fig2() to draw more complex figures by getting input points and using commands like "line", "arc", and "line" to construct the shapes. Key Auto Lisp concepts introduced are defun to define functions, setq for assignment, getpoint to specify points, and commands like

Uploaded by

Mohit Jani
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