0% found this document useful (0 votes)
18 views10 pages

Autolisp My

The document contains multiple AutoLISP programs for AutoCAD, including a program to create a cardiod effect, file handling, animation of a rectangle, and menu customization. Each program demonstrates specific functionalities such as drawing shapes, writing to and reading from files, and creating custom menus. The code snippets are structured to allow user interaction and graphical output within the AutoCAD environment.

Uploaded by

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

Autolisp My

The document contains multiple AutoLISP programs for AutoCAD, including a program to create a cardiod effect, file handling, animation of a rectangle, and menu customization. Each program demonstrates specific functionalities such as drawing shapes, writing to and reading from files, and creating custom menus. The code snippets are structured to allow user interaction and graphical output within the AutoCAD environment.

Uploaded by

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

3i)program to get innovative effect(optional)

(defun C:CARDIOD()
(command "limits" (list 0 0) (list 200 200)"zoom" "a")
(setq j 40.0)
(setq pt1 (getpoint "\nEnter Center point : "))
(command "circle" pt1 j)
(setq i 0)
(setq k 1)
(setq k 1)
(while (<= i 720)
(setq x1 (* 30 (cos (/ (* i pi) 360.0)))
y1 (* 30 (sin (/ (* i pi) 360.0)))
x2 (expt (+ x1 j) 2)
y2 (expt y1 2)
r1 (expt (+ x2 y2) 0.5)
pt2x(+ x1 (car pt1))
pt2y(+ y1 (cadr pt1))
pt2 (list pt2x pt2y)
)
(command "color" k)
(command "circle" pt2 r1)
(setq i (+ i 15))
(setq k (+ k 1))
)
)
3F) Program to get file handling using lisp program:
(defun C:FH()
(setq sf(open "Have a good day.txt" "w")
fc(getstring "\nEnter text to write in the file: "))
(write-line fc sf)
(close sf)
(setq sf (open "Have a good day.txt" "r"))
(princ "\nThe first line in file says that : ")
(setq rl (read-line sf))
(princ rl)
(princ)
(close sf)
)
3g) program to get animation in AutoCAD using lisp
programming:
(defun c:animateRect ()
(setq p1 (getpoint "\nSpecify first corner: "))
(setq p2 (getcorner p1 "\nSpecify opposite corner: "))
(setq num_frames 50)
(setq delta_x (/ (- (car p2) (car p1)) num_frames))
(setq delta_y (/ (- (cadr p2) (cadr p1)) num_frames))
(defun draw-rectangle (p1 p2)
(command "_.rectangle" p1 p2)
)
(defun animate-rectangle (current_frame)
(setq current_x (+ (car p1) (* delta_x current_frame)))
(setq current_y (+ (cadr p1) (* delta_y current_frame)))
(command "_.UCS" "_World")
(command "_.PLAN" "_World")
(command "_.REGEN")
(command "_.-view" "_Top")
(draw-rectangle p1 (list current_x current_y))
(if (< current_frame num_frames)
(progn
(setq current_frame (1+ current_frame))
(animate-rectangle current_frame))
)
)
(animate-rectangle 0)
(princ)
)
(c:animateRect)
3H) program for menu customization:
(defun c:myCircle (/ radius)
(setq radius (getreal "\nEnter the radius of the circle: "))
(command "circle" "0,0" radius)
)
(defun c:createCustomMenu ()
(if (not (member "MyCustomMenu" (menucmd "menu")))
(progn
(setq customMenu (menucmd "menu" "MyCustomMenu"))
(setq newItem (menucmd "additem" customMenu "MyCircle"'c:myCircle))
(setq addStat (menucmd "addstat" newItem))
(princ "\nCustom menu created successfully.")
)
(princ "\nCustom menu already exists.")
)
)

You might also like