13 September 2012

How to draw circle or donuts using AutoLISP|| How to draw circle or donut in AutoCAD using AutoLISP

                           Hi Friends in this article i will explain about how to draw circle or donut in  AUTOLISP.
                           In previous articles i explained about  How to draw line in AutoCAD using AutoLISP,How to draw PLINE in AutoCAD and How to draw PLINE in AutoCAD using AutoLISP.,how to write the code for fillet in AutoLISP.

How to draw DONUT or circle using AUTOLISP.
What is the use of AutoLISP:
· AutoLisp is a programming language is used for the AUTOCAD.
· Autolisp is a language when we write the code in .lsp and execute it then it will return the value.
· Autolisp is a lisp programming language of AUTODESK’s implementation.
· We can write user defined functions in autolisp for the AUTOCAD.
· Autolisp is used to create programs that will generate drawings automatically in the AUTOCAD.
· Autolisp interface is not there in the AUTOCAD LT.
Let we know about how to create DONUT.
Before that we know about how to create Circle in Autolisp.
· Type VLISP or VLIDE in the command of AUTOCAD then Autolisp editor is opened.
· Write the following code.
Every program in autolisp is like below.
(defun c:display()
(princ “Roja”)
)
This is the simple program to print “Roja”
For create the circle in autocad write the following code
(defun c:drawCircle()
(setq c1(strcat “0” “,” “0”)) ;;first point
(setq c2(strcat “25” “,” “25”)) ;;second point
;; the between these points c1 and c2 shows the radius of the circle
(command “circle” c1 c2 “”) ;;draw the circle
)
· Then save the file as circle.lsp
· Go to AutoCAD and type “ (load “circle”) and press ENTER.
· Type drawCircle.
· Then the circle will create in AutoCAD with radius 25.
Let we know how to draw the DONUT in autolisp.
· Type VLISP or VLIDE in the command of AUTOCAD then Autolisp editor is opened.
· Write the following code.
(defun c:drawDonut()
(setq c1(strcat “0” “,” “0”)) ;;first point
(command "_.donut" 0 15 c1 "") ;;draw the donut
;;in the above shows
;; 0 specifies the inside diameter donut.
;; 15 specifies the outside diameter donut
;; c1 specifies the centre of DONUT
)
· Then save the file as donut.lsp
· Go to AutoCAD and type “ (load “donut”) and press ENTER.
· Type drawDonut.
· Then the donut will create in AutoCAD.

2 comments: