111910116_CG_AUTOLISP
111910116_CG_AUTOLISP
111910116_CG_AUTOLISP
Assignment 1
1 a ) Initials of student
Inputs- pt1- reference point
name- first name, middle- middle name, surname
:PROGRAM 1a,
:PROGRAM TO DISPLAY INITIALS
(defun C:Initials ()
(setq pt1(getpoint "\n Enter the corner refernce point"))
(setq name(getstring "\nEnter first name "))
(setq middle(getstring "\n Enter middle name"))
(setq surname(getstring "\nEnter surname "))
(setq in1(substr name 1 1))
(setq in2(substr middle 1 1))
(setq in3(substr surname 1 1))
(setq final(strcase (strcat in1 in2 in3)))
(command "text" pt1 20 0 final "")
)
1 b)Title block with students name, mis div batch etc
Inputs- pt1= enter the corner of block
,h=enter the height of text
;PROGRAM 1 b
;program to create title block
(defun c:title()
(Setq pt1(getpoint "\n Select the 1st corner point of text box")
h(getreal "\n Enter the text height")
pt2(list (car pt1) (- (cadr pt1) (* 2.4 h)))
pt3(list (car pt2) (- (cadr pt2) (* 2.4 h)))
pt4(list (car pt3) (- (cadr pt3) (* 2.4 h)))
pt5(list (car pt4) (- (cadr pt4) (* 2.4 h)))
A(list (- (car pt1) (* 0.42 h)) (+ (cadr pt1) (* 1.6 h)))
A1(list (+ (car A) (* 25 h)) (cadr A))
B(list (- (car pt2) (* 0.42 h)) (+ (cadr pt2) (* 1.6 h)))
B1(list (+ (car B) (* 25 h)) (cadr B))
C(list (- (car pt3) (* 0.42 h)) (+ (cadr pt3) (* 1.6 h)))
C1(list (+ (car C) (* 25 h)) (cadr C))
D(list (- (car pt4) (* 0.42 h)) (+ (cadr pt4) (* 1.6 h)))
D1(list (+ (car D) (* 25 h)) (cadr D))
E(list (- (car pt5) (* 0.42 h)) (+ (cadr pt5) (* 1.6 h)))
E1(list (+ (car E) ( * 25 h)) (cadr E))
F(list (- (car pt5) (* 0.42 h)) (- (cadr pt5) h))
F1(list (+ (car F) (* 25 h)) (cadr F))
)
(command "text" pt1 h 0 "COLLEGE OF ENGINEERING PUNE")
(command "text" pt2 h 0 "TEJRAJ DEVRAJ PATIL")
(command "text" pt3 h 0 "MIS:111910116")
(command "text" pt4 h 0 "BATCH F ")
(command "text" pt5 h 0 "DIV 2, SY-MECH")
(command "line" A A1 "")
(command "line" B B1 "")
(command "line" C C1 "")
(command "line" D D1 "")
(command "line" E E1 "")
(command "line" F F1 "")
(command "line" A B C D E F "")
(command "line" A1 B1 C1 D1 E1 F1 "")
)
Assignment 2
2 a) Square with diagonals
Inputs: - pt1=1st corner of square,
L= length of side
;PROGRAM 2a
;program to draw a square with diagonal crossing lines
(defun c:square()
(setq pt1(getpoint "\n Enter the first corner point"))
(setq L(getreal "\n Enter square side length"))
(setq pt2(polar pt1 0 L))
(setq pt3(polar pt2 (/ pi 2) L))
(setq pt4(polar pt3 pi L))
(command "line" pt1 pt2 pt3 pt4 pt1 "")
(command "line" pt1 pt3 "")
(command "line" pt2 pt4 "")
(princ)
)
;PROGRAMME 2b
;program to draw a rectangle with diagonal crossing lines.
(defun c:rect()
(setq pt1(getpoint "\n Enter the first corner point"))
(setq L(getreal "\n Enter length of rectangle"))
(setq W(getreal "\n Enter width of rectangle"))
(setq pt2(polar pt1 0 L))
(setq pt3(polar pt2 (/ pi 2) W))
(setq pt4(polar pt3 pi L))
(command "line" pt1 pt2 pt3 pt4 pt1 "")
(command "line" pt1 pt3 "")
(command "line" pt2 pt4 "")
(princ)
)
Assignment 3
Regular polygon with 9 sides
Inputs-
, p1= starting point
, l= length of sides
;PROGRAM 3
;program to draw a regular polygon
(defun c:poly9()
(setq p1(getpoint "\n Enter start point"))
(setq n 9)
(setq l(getreal "\n Enter length of sides"))
(setq angv(/ 360 n))
(setq ang 0)
(setq i 1)
(command "pline" p1)
(while (<= i n)
(setq p2(polar p1 (* (/ pi 180) ang) l))
(command p2)
(setq ang(+ ang angv))
(setq p1 p2)
(setq i(+ i 1))
)
(command "")
(princ)
)
Assignment 4
Concentric circles
Inputs: -
, p1= centre of circles
, n= number of concentric circles
;PROGRAM 4
;program to draw concentric circles
(defun c:concircles()
(setq p1(getpoint "\n Enter the center point of the circle"))
(setq r 8)
(setq n(getint "\n Enter number of circles"))
(setq d 8)
(repeat n
(command "circle" p1 r)
(setq r(+ r d))
)
(princ)
)
Assignment 5
Parametric program- rounded top counter-sunk head rivet
Inputs-
,pt1- enter bottom left corner of drawing
,d= diameter of rivet
;PRPGRAM 5
;program to draw two views of a round top countersunk head rivet
(defun c:rivet()
(setq pt1(getpoint "\n Enter the corner point of drawing"))
(setq d(getreal "\n Enter diameter of rivet"))
(setq pt2(polar pt1 (/ pi 2) (* 1.5 d)))
(setq pt3(polar pt2 (/ pi 2) (* 0.25 d)))
(setq pt4(polar pt3 pi (* 0.25 d)))
(setq pt6(polar pt4 0 (* 1.5 d)))
(setq pt7(polar pt3 0 d))
(setq pt8(polar pt2 0 d))
(setq pt9(polar pt1 0 d))
(command "line" pt1 pt2 pt4 pt6 pt8 pt9 pt1 "")
(command "line" pt2 pt8 "")
(setq pt10(polar pt1 0 (* 0.5 d)))
(setq pt5(polar pt10 (/ pi 2) (* 2 d)))
(command "arc" pt4 pt5 pt6 "")
(setq pt11(polar pt5 (/ pi 2) (* 1.5 d)))
(command "circle" pt11 (/ (* 1.5 d) 2))
(command "linetype" "s" "hidden" "")
(command "circle" pt11 (/ d 2))
(command "linetype" "s" "continuous" "")
(princ)
)
Assignment 6
File handling
Inputs- d= enter pin dia, l=enter pin length, p= enter intersection point
;PROGRAM 6
;program for file handling
(defun c:FH()
(setq d(getreal "\n Enter the pin diameter")
l(getreal "\n Enter pin length")
p(getpoint "\n Enter intersection point")
r(/ d 2.0)
p1(polar p 0 r)
p2(polar p1 (/ pi -2.0) l)
p3(polar p2 pi d)
p4(polar p3 (/ pi 2.0) l)
p5(polar p 0 (* 1.5 r))
p6(polar p pi (* 1.5 r))
rad(* 0.75 d)
dl(rtos d)
ll(rtos l)
)
(command "limits" (list 0 0) (list 29 210)
"Pline" p1 p2 p3 p4 ""
"Pline" p5 p6 ""
"arc" p5 "e" p6 "r" rad)
(setq fp(open "c:/map.txt" "w"))
(setq ar(+ (* r l) (/ (* pi d d) 8)))
(setq ar1(rtos ar)
m1(strcat "pin diameter =" dl)
m2(strcat "pin length=" ll)
m3(strcat "area=" ar1))
(write-line m1 fp)
(write-line m2 fp)
(write-line m3 fp)
(close fp)
(setq fp1(open "c:/map.txt" "r"))
(read-line fp1)
(close fp1)
)
OUTPUT-
Pin diameter= d
Pin Lenght= l
Area