9 AutoLisp Programming : All Commands


=============================================

1 AutoLisp Programming : Introduction

2 AutoLisp Programming : Basic Knowledge Essentials

3 AutoLisp Programming : DataTypes

4 AutoLisp Programming : Arithmetic Functions

5 AutoLisp Programming : Trignometric Functions

6 AutoLisp Programming : Mathematical Functions

7 AutoLisp Programming : Exercise 01

8 AutoLisp Programming : Structure Functions

9 AutoLisp Programming : All Commands

=============================================

 

  • 1 to N

(setq n(getint “Enter the no:”))

(setq i 0)

(while (< i n)

   (setq i(+ i 1))

          (print i)

  )

 

  • 2Digitrevcerse

(setq n(getint “Enter the two digit number:”)

      a(/ n 10)

      b(- n (* a 10))

      c(+ (* b 10) a)

      )

(print c)

 

  • 3digalternate

(setq n(getint “Enter the number:”)

      a(/ n 100)

      b(- n (* a 100))

      c(/ b 10)

      d(- b (* c 10))

      e(+ (* d 100) ( * c 10) a)

      )

  (print e)

 

  • asdaf

(DEFUN C:REC1()

(command “erase” “all” “”)

(command “osnap” “off”)

  (SETQ L(getint “enter length:”)

        p1 (getpoint “specify the start point”)

          p2 (polar p1 0 l)

          p3 (polar p2 (/ (* pi 90)180)l)

          p4 (polar p3 pi l)

          )

  (command “line” p1 p2 p3 p4 p1 “”)

  (command “arc” p1 “e” p2 “r” (/ l 2))

  (command “arc” p2 “e” p3 “r” (/ l 2))

  (command “arc” p3 “e” p4 “r” (/ l 2))

  (command “arc” p4 “e” p1 “r” (/ l 2))

  (command “zoom” “e” )

  (command “regen”)

  )

 

  • C-Sec

(defun c:cseC()

  (command “erase” “all” “”)

  (command “osnap””off”)

  (setq a(getint “Enter thevalue of a:”)

          b(getint “Enter the value of b:”)

          c(getint “Enter the valueod c:”)

          p1(getpoint “specify p1:”)

          p2(polar p1 0 a)

          p3(polar p2 (/(* pi 90)180) b)

          p4(polar p3 pi (- a b))

          p5(polar p4 (/(* pi 90)180) (- c(* 2 b)))

          p6(polar p5 0 (- a b))

          p7(polar p6 (/(* pi 90)180) b)

          p8(polar p7 pi a)

          h1(polar p1 (/(* pi 45)180) (/ b 2))

          )

  (command “pline” p1 p2 p3 p4 p5 p6 p7 p8 p1 “”)

  (command “bhatch” “p” “ansi34” 6 0 h1 “”)

  (command”zoom” “e”)

  (command “regen” )

  )

 

  • C-Sec With Mirror

(defun c:cseC()

  (command “erase” “all” “”)

  (command “osnap””off”)

  (setq a(getint “Enter thevalue of a:”)

          b(getint “Enter the value of b:”)

          c(getint “Enter the valueod c:”)

          p1(getpoint “specify p1:”)

          p2(polar p1 (/(* pi 270)180) (/ c 2))

          p3(polar p2 0 a)

          p4(polar p3 (/(* pi 90)180) b)

          p5(polar p4 pi (- a b))

          p6(polar p5 (/(* pi 90)180) (- (/ c 2) b))

        h1(polar p2 (/(* pi 45)180) (/ b 2))

          )

  (command “pline” p1 p2 p3 p4 p5 p6 “”)

  (command “mirror” “all” “” p1 p6 “n” )

  (command “bhatch” “p” “ansi34” 6 0 h1 “”)

  (command”zoom” “e”)

  (command “regen” )

  )

 

  • E-Sec

(defun c:esec()

  (command “erase” “all” “”)

  (command “osnap” “off”)

  (defun ang(x) (/(* pi x)180))

  (setq a(getint “Enter the value of a:”)

          b(getint “Enter the value of b:”)

          c(getint “Enter the value of c:”)

          p1(getpoint “Spacify p1:”)

          p2(polar p1 (ang 270) (/ c 2))

          p3(polar p2 0 a)

          p4 (polar p3 (ang 90) b)

          p5(polar p4 pi (- a b))

          p6(polar p5 (ang 90) (- (/ c 2) (/ (* 3 b) 2)))

          p7(polar p6 0 (- a b))

          p8(polar p7 (ang 90) (/ b 2))

          h1(polar p5 pi (/ b 2))

          )

  (command “pline” p1 p2 p3 p4 p5 p6 p7 p8 “”)

  (command “mirror” “all” “” p1 p8 “n” )

  (command “bhatch” “p” “stars” 8 0 h1 “” )

  (command “zoom” “e” )

  (command “regen” )

 )

 

  • Flange

(defun c:flange()

  (command “erase” “all” “”)

  (command “osnap” “off”)

  (defun ang(x) (/(* pi x)180))

  (setq id(getint  “Enter the value of ID:”)

          cd(getint  “Enter the value of CD:”)

          fd(getint  “Enter the value of FD:”)

        pcd(getint  “Enter the value of PCD:”)

        od(getint  “Enter the value of OD:”)

          hd(getint  “Enter the value of HD:”)

          fh(getint  “Enter the value of FH:”)

          th(getint  “Enter the value of TH:”)

          P1(GETPOINT “Enter p1:”)

          p2(polar p1 0 (/ od 2))

          p3(polar p2 (ang 90) fh)

          p4(polar p3 pi (- (/ od 2) (/ fd 2)))

          p5(polar p4 (ang 90) (- th fh))

          p6(polar p5 pi (/ fd 2))

          c1(polar p6 0 (/ id 2))

          c2(polar c1 (ang 270)(- th 5))

          c3(polar c2 0 (- (/ cd 2) (/ id 2)))

          c4(polar c3 (ang 270) 5)

          p7(polar c2 pi (/ id 2))

          o1(polar p4 0 (- (/ pcd 2) (/ fd 2)))

          o2(polar o1 (ang 270) fh)

          h1(polar p2 (ang 120) (/ fh 4))

          h2(polar p4 (ang 270) 5)

          )

  (command “line” p1 p2 p3 p4 p5 p6 “”)

  (command “line” c1 c2 c3 c4″”)

  (command “line” c2 p7″”)

  (command “line” p6 p7 “”)

  (command “line”O1 o2 “”)

  (setq a1(entlast))

  (command “offset” (/ hd 2) a1 “m” p3 “” “”)

  (command “offset” (/ hd 2) a1 “m” p4 “” “”)

  (command “bhatch” “p” “ansi31” 6 0 h1 “”)

  (command “bhatch” “p” “ansi31” 6 0 h2 “”)

  (command “mirror” “all” “” p1 p6 “n” “”)

)

         

         

 

 

  • H-Sec

(defun c:hsec()

  (command “erase” “all” “”)

  (command “osnap” “off” )

  (setq a(getint “Enter the value of a:”)

          b(getint “Enter the value of b:”)

          c(getint “Enter the value of c:”)

          p1(getpoint “specify p1:”)

          p2(polar p1 (/(* pi 270)180) (/ b 2))

          p3(polar p2 0 a)

          p4(polar p3 (/(* pi 90)180) (- (/ b 2) (/ a 2)))

          p5(polar p4 0 c)

          p6(polar p5 (/(* pi 270)180) (- (/ b 2) (/ a 2)))

          p7(polar p6 0 a)

          p8(polar p7 (/(* pi 90)180) (/ b 2))

          h1(polar p8  (/(* pi 120)180) (/ a 4))

          )

  (command “pline” p1 p2 p3 p4 p5 p6 p7 p8 “”)

  (command “mirror” “all” “” p1 p8 “n”)

  (command “bhatch” “p” “ansi31” 4 0 h1 “”)

  (command “zoom” “E”)

  (command “regen”)

  )

 

  • IBhach

`(defun c:isec()

  (command “erase” “all” “”)

  (command “osnap” “off”)

   (setq a(getreal “Enter the value a:”)

         b(getreal “Enter the value b:”)

         c(getreal “Enter the value c:”)

        p1(getpoint “specify p1”)

          p2(polar p1 0 (/ a 2))

          p3(polar p2(/(* pi 90)180) b)

          p4(polar p3 pi (- (/ a 2)(/ b 2)))

          p5(polar p4(/(* pi 90)180) (- c (* 2 b)))

          p6(polar p5 0 (- (/ a 2)(/ b 2)))

          p7(polar p6(/(* pi 90)180) b)

          p8(Polar p7  pi (/ a 2))

          h1(polar p1(/(* pi 45)180)(/ b 2))

   );setq is closed

  (command “pline” p1 p2 p3 p4 p5 p6 p7 p8  “”)

  (command “mirror” “all” “” p1 p8 “n”)

  (command “bhatch”  “p”  “ansi31″ 4 0 h1″”)

  (command “zoom” “e”)

  (command “regen”)

 )

 

  • I-Sec

(defun c:isec()

  (command “erase” “all” “”)

  (command “osnap” “off”)

  (setq a(getreal “enter the value of a:”)

          b(getreal “enter the value of b:”)

          c(getreal “enter the value of c:”)

          p1(getpoint “specify p1:”)

          p2(polar p1 0 (/ a 2))

          p3(polar p2 (/(* pi 90)180) b)

          p4(polar p3 pi (- (/ a 2) (/ b 2)))

          p5(polar p4 (/(* pi 90)180) (- c (* 2 b)))

          p6(polar p5 0 (- (/ a 2) (/ b 2)))

          p7(polAR P6 (/(* PI 90)180) B)

          P8(POLAR P7 PI (/ A 2))

          H1(POLAR P1 (/(* pi 90)180) (/ B 2))

          )

  (COMMAND “LINE” P1 P2 P3 P4 P5 P6 P7 P8 “”)

  (COMMAND “MIRROR” “ALL” “” P1 P8 “N” “”)

  (COMMAND “BHATCH” “P” “ANSI31″ 8 0 H1″” “”)

  (COMMAND “ZOOM” “e”)

  (COMMAND “REGEN”)

  )

 

  • L-Sec

`(defun c:lsec()

  (command “erase” “all” “”)

  (command “osnap” “off”)

   (setq a(getint “Enter the value a”)

         b(getint “Enter the value b”)

         c(getint “Enter the value c”)

           p1(getpoint “specify p1”)

          p2(polar p1 0 a)

          p3(polar p2(/(* pi 90)180) b)

          p4(polar p3 pi (- a b))

          p5(polar p4(/(* pi 90)180) (- c b))

          p6(polar p5 pi b)

          h1(polar p1 (/(* pi 45)180) (/ b 2))

          )

  (command “pline” p1 p2 p3 p4 p5 p6 p1 “”)

  (command “bhatch” “p” “STARS” 6 45 h1 “”)

  (command “zoom” “e”)

  (command “regen”)

  )

 

  • Maxnum

(setq a(getint “Enter number n1:”)

      b(getint “Enter number n2:”)

      c(getint “Enter number n3:”)

 

      { if(> n1  n2 > n1 n3)

      (print ” max num n1″)

     

      else if(> n2 n1 > n2 n3)

      (print “max num n2”)

     

      else if(> n3  n1 > n3 n2)

       (print “max num n3”)

      }

       )

 

  • Mul

 

;write the program given multiplication  n number;

 

(setq n(getint “enter number:”))

(setq i 0)

(setq m 1)

 

(while( < i n)

(setq i(+ i 1))

(setq m(* m i))

(print m)

  )

 

  • Obj

(defun c:obj()

  (command “erase” “all” “”)

  (command “osnap” “off” “”)

  (setq          p1(getpoint”Specify point p1::”)

          p2(polar p1 0 58)

          p3(polar p2 (/ (* pi 90)180 )10)

          p4(polar p3 (/ (* pi 180)180 )6)

          p5(polar p4 (/ (* pi 90)180 )38)

          p6(polar p5 (/ (* pi 180)180 )46)

          p7(polar p6 (/ (* pi 270)180 )38)

          p8(polar p7 (/ (* pi 180)180 )6)

          p9(polar p6 0 23)

          p10(polar p9 (/ (* pi 270)180 )20)

          p11(polar p4 pi 10)

          p12(polar p11(/ (* pi 270)180 )8 )

          )

  (command “pline” p1 p2 p3 p4 p5 p6 p7 p8 p1 “” )

  (setq a(entlast))

  (command “region” a “”)

  (setq b(entlast))

  (command “extrude” b “” 60 “”)

  (setq c(entlast))

  (command “cylinder” p10  “d” 24 65 “”)

  (setq d(entlast))

  (COMMAND “BOX” P12 “L” -50 -24 -14 “”)

  (setq e(entlast))

  ;(command “subtract” c “” d “” “”)

  (command “zoom””e”””)

  (command “regen”)

 )

 

  • Odd and Even

(setq n (getint “enter number:–“))

(setq a( / n 2))

(setq b( – n (* a 2)))

     

        (if(= b 0)

             (print “the number is even”)

             (print “the number is odd”)

          )                  

 

  • Offcir

(DEFUN C:offcir()

 

(command “erase” “all” “”)

 (command “osnap” “off”)

 

 (SETQ r(getreal “enter radius”)

        p1 (getpoint “specify the center point”)

          p2 (polar p1 0 (* 10 r))

          )

  (command “circle” p1 r)

  (setq a(entlast))

  (command “offset”(/ r 4) a “m” p2 p2 p2 p2″” “”)

  (command “zoom” “e”)

  (command “regen”)

  )

 

  • OffRec

(DEFUN C:offrec()

 

(command “erase” “all” “”)

 (command “osnap” “off”)

 

 (SETQ L(getint “enter length”)

       w(getint “enter width”)

        p1 (getpoint “specify the start point”)

          p2 (polar p1 0 l)

          p3 (polar p2 (/ (* pi 90)180)w)

          p4 (polar p3 pi l)

          )

  (command “pline” p1 p2 p3 p4 p1 “”)

  (setq c(entlast))

  (command “offset”(/ l 4 ) c “m” p1 p1 p1 p1 p1 p1″” “”)

  (command “zoom” “e”)

  (command “regen”)

  )

 

  • Piramid

(defun c:p1()

  (command “erase” “all” “”)

  (command “osnap” “off”)

  (setq r (getint “enter the radius :”)

          n (getint “enter no of step:”)

          p1(getpoint “enter center point:”))

          (command “circle” p1 r)

          (setq i 2)

 

          (while (> n 1)

            (setq p1 (polar p1(/( * pi 240)180) ( * 2 r)))

            (command “circle” p1 r)

                   (setq a1(entlast))

            (command “array” a1 “” “r” 1 i (* 2 r))

            (setq i (+ i 1))

            (setq n (- n 1))

            )

 

           

           (command “zoom” “e”)

           (Command “regen”)

 )

         

 

  • Polacir

(defun c:p1()

  (command “erase” “all” “”)

  (command “osnap” “off”)

  (setq r1 (getint “enter the r1:”)

          r2(getint “enter the r2:”)

          n(getint “enter the no. of item”)

          a(getint “enter the angle of array:”)

          p1(getpoint “Specify p1:”)

          p2(polar p1 0 r1)

          )

  (command “circle” p1 r1)

  (command “circle” p2 r2)

  (setq a1(entlast))

  (command “array” a1 “” “p” p1 n a “”)

  (command “zoom ” “e” “”)

  (command “regen”)

  )

 

  • Pol-Line

(defun c:pol1()

  (command “erase” “All” “”)

  (command “osnap” “off”)

  (setq l(getint “Enter the length of edge:”)

          p1(getpoint “specify p1:”)

          p2(polar p1 0 l)

          p3(polar p2 (/(* pi 72)180) l)

          p4(polar p3 (/(* pi 144)180) l)

          p5(polar p4 (/(* pi 216)180) l)

          )

  (command “line” p1 p2 p3 p4 p5 p1 “”)

  (command “zoom””e”)

  (command “regen”)

  )

 

  • Polygon

  (defun c:p1()

  (command “erase” “all” “”)

  (command “osnap” “off”)

  (setq n(getint “Enter no of side:”)

          r(getint “enter the radius:”)

          p1(getpoint “enter specify point:”)

          )

  (command “polygon” n p1   “i”  r “”)

  (command “zoom” “e”)

  (command “regen”)

  )

 

 

         

 

 

 

  • Print 1 to N

(setq n(getint “Enter the no:”))

(setq i 0)

(while (< i n)

   (setq i(+ i 1))

(print i)

  );while closed

 

  • Ract

(DEFUN C:REC1()

 

(command “erase” “all” “”)

 (command “osnap” “off”)

 

 (SETQ  L(getint “enter length”)

        w(getint “enter width”)

        p1 (getpoint “specify the start point”)

          p2 (polar p1 0 l)

          p3 (polar p2 (/ (* pi 90)180)w)

          p4 (polar p3 pi l)

        P5 (POLAR P1 0 (/ L 2))

        P6(POLAR P5 (/(* PI 90)180) W)

          )

  (command “line” p1 p2 p3 p4 p1 “”)

  (COMMAND “CIRCLE” “2P” P5 P6 )

  (command “zoom” “e”)

  (command “regen”)

)

 

  • Rec

(defun c:rec1()

  (Command “erase” “all” “”)

  (Command “osnap” “off”)

 

 

  (setq l (getreal “specify the length of rectangle:”)

        w (getreal “specify the width of rectangle:”)

        a (getint “specify rotation angle:”)

          p1 (getpoint “specify corner point:”)

          p2 (polar p1 0 l)

          p3 (polar p2 (/ (* pi 90) 180) w)

          p4 (polar p3 (/ (* pi 180) 180) l)

        p5 (polar p1 0 (/ l 2))

          p6 (polar p4 0 (/ l 2))

         

   );setq close

  (command “linetype” “s” “center” )

  (command “line” p1 p2 p3 p4 p1 “”)

  (command “circle” “2p” p5 p6)

  (command “rotate” “all” “” p1 a)

  (command “zoom” “e”)

  (command “regen”)

 );defun close

 

  • Rec1

(DEFUN C:REC1()

(command “erase” “all” “”)

(command “osnap” “off”)

  (SETQ L(getint “enter length”)

       w(getint “enter width”)

      

        p1 (getpoint “specify the start point”)

          p2 (polar p1 0 l)

          p3 (polar p2 (/ (* pi 90)180)w)

          p4 (polar p3 (/ (* pi 180)180)l)

          p5 (polar p1 0 ( / l 2))

          p6 (polar p3 pi (/ l 2))

          )

  (command “line” p1 p2 p3 p4 p1 “”)

  (command “circle” “2p” p5 p6)

  );defun close

 

  • Rect1

(DEFUN C:REC1()

(command “erase” “all” “”)

(command “osnap” “off”)

  (SETQ L(getint “enter length”)

       w(getint “enter width”)

      

        p1 (getpoint “specify the start point”)

          p2 (polar p1 0 l)

          p3 (polar p2 (/ (* pi 90)180)w)

          p4 (polar p3 (/ (* pi 180)180)l)

          p5 (polar p1 0 ( / l 2))

          p6 (polar p3 pi (/ l 2))

          )

  (command “line” p1 p2 p3 p4 p1 “”)

  (command “circle” “2p” p5 p6)

  (command “zoom” “e” )

  (command “regen””all”)

  );defun close

 

  • Rect-Array

(DEFUN C:REC1()

 

(command “erase” “all” “”)

 (command “osnap” “off”)

 

 

 (setq L(getint “enter length”)

       r(getint “Enter row”)

       c(getint “Enter coloum”)

       p1(getpoint “specify corner point “)

       p2 (polar p1 0 l)

       p3 (polar p2 (/ (* pi 90)180)l)

       p4 (polar p3 pi l)

        )

  (command “pline” p1 p2 p3 p4 p1 “”)

  (setq a1(entlast))

  (command “array” a1 “” “r” r c (* 2 l) (* 2 l)””)

  (command “zoom” “e”)

  (command “regen”)

  )

 

 

  • Rext

(defun c:rext1()

  (command “erase” “all” “”)

  (command “osnap” “off” “”)

  (setq l(getint “Enter length ::”)

          w(getint “Enter width ::”)

          h(getint “Enter height ::”)

          p1(getpoint”Specify point p1::”)

          p2(polar p1 0 l)

          p3(polar p2 (/ (* pi 90)180 )w)

          p4(polar p3 (/ (* pi 180)180 )l)

          )

  (command “pline” p1 p2 p3 p4 p1 “” )

  (setq a(entlast))

  (command “region” a “”)

  (setq b(entlast))

  (command “extrude” b “” h “”)

  (setq c(entlast))

  (command “color”  “red” c)

  (COMMAND “ZOOM””E”)

  (COMMAND “REGEN”)

  )

 

  • Rext2

(defun c:rext3()

  (command “erase” “all” “”)

  (command “osnap” “off” “”)

  (setq l(getint “Enter length ::”)

          w(getint “Enter width ::”)

          h(getint “Enter height ::”)

          p1(getpoint”Specify point p1::”)

          p2(polar p1 0 l)

          p3(polar p2 (/ (* pi 90)180 )w)

          p4(polar p3 (/ (* pi 180)180 )l)

          )

  (command “pline” p1 p2 p3 p4 p1 “” )

  (setq a(entlast))

  (command “region” a “”)

  (setq b(entlast))

  (command “extrude” b “” h “”)

  (setq c(entlast))

  (command “color”  “blue” c)

  (COMMAND “ZOOM””E”)

  (COMMAND “REGEN”)

  )

  • Sec

(defun c:sec()

  (command “erase” “all” “”)

  (command “osnap” “off”)

   (setq a(getint “Enter the value a:”)

         b(getint “Enter the value b:”)

         c(getint “Enter the value c:”)

           d(getint “Enter the value d:”)

           )

  (setq p1(getpoint “specify p1”)

          p2(polar p1 0 a)

          p3(polar p2(/(* pi 90)180) b)

          p4(polar p3(/(* pi 180)180) (- a d))

          p5(polar p4(/(* pi 90)180) b)

          p6(polar p5 pi d)

          p7(polar p3(/(* pi 180)180)(/ (- a d) 2))

          p8(polar p7(/(* pi 270)180) b)

          c7p(polar p7 0 (/ c 6))

          c8p(polar c7p (/(* pi 270)180) b)

          c7q(polar p7 (/(* pi 180)180) b)

          c8q(polar c7q (/(* pi 270)180) b)

          )

  (command “line” p1 p2 p3 p4 p5 p6 p1  “”)

  (command “line” c7p c8p “”)

  (command “line” c7q c8q “”)

  (command “linetype” “s” “center” “”)

  (command “line” p1 p6 “”)

  (command “line” p7 p8 “”)

  (command “mirror” “all” “” p1 p6 “n” “”)

  (command “zoom” “e”)

  (command “regen”)

  )

 

  • Solid

(defun c:b1()

  (command “vscurrent” “r”)

  (command “vpoint” “1,-1,1”)

 (command “erase” “all” “”)

  (command “osnap” “off”)

  (setq p1(getpoint “specify corner point”)

          l(getint “l”)

          w(getint “w”)

          h(getint “h”)

          )

  (command “color” “red”)

  (command “box”  p1 “l” l w h “”)

  (command “zoom” “e”)

  (command “regen”)

  )

 

  • Spiral

(DEFUN C:sp1()

 

(command “erase” “all” “”)

(command “osnap” “off”)

 

  (setq r (getint “enter the radius :”)

        p1(getpoint “specify start point p1”)

          p2(polar p1 pi (* 2 r))

          p3(polar p1 0 (* 2 r))

          p4(polar p1 (/(* pi 90)180)  (* 20 r))

          p5(polar p1 (/(* pi 270)180) (* 20 r))

          )

         

          (command “arc” p1 “e” p2 “r” r)

        (setq a1 (entlast))

        (command “arc” p2 “e” p3 “r” (* 2 r))

        (setq a2 (entlast))

        (command “offset” (* 2 r)  a1   “m” p4 p4 p4 “” “”)

        (command “offset” (* 2 r)  a2    “m”  p5 p5 p5 “” “”)

        (command “zoom” “e”)

        (command “regen” )

       )

 

 

           

 

 

 

 

  • Sqrtarc

(DEFUN C:REC1()

(command “erase” “all” “”)

(command “osnap” “off”)

  (SETQ L(getint “enter length:”)

        p1 (getpoint “specify the start point”)

          p2 (polar p1 0 l)

          p3 (polar p2 (/ (* pi 90)180)l)

          p4 (polar p3 pi l)

          )

  (command “line” p1 p2 p3 p4 p1 “”)

  (command “arc” p1 “e” p2 “r” (/ l 2))

  (command “arc” p2 “e” p3 “r” (/ l 2))

  (command “arc” p3 “e” p4 “r” (/ l 2))

  (command “arc” p4 “e” p1 “r” (/ l 2))

  (command “zoom” “e” )

  (command “regen”)

  )

 

  • Subnum

(setq p(getint “Enter the number::”))

(setq q(getint “Enter the number::”))

          (setq u(- p q))

 

          (if (> u 0)

            (print u)

          (PRINT “VALUE INVALID”))

 

  • Subtract

(defun c:SUB1()

  (command “erase” “all” “”)

  (command “osnap” “off” “”)

  (setq l(getint “Enter length ::”)

          w(getint “Enter width ::”)

          h(getint “Enter height ::”)

          h1(getint “Enter height of cylinder ::”)

          r(getint “enter the radius of cylinder::”)

          p1(getpoint”Specify point p1::”)

          p2(polar p1 0 l)

          p3(polar p2 (/ (* pi 90)180 )w)

          p4(polar p3 (/ (* pi 180)180 )l)

          p5(polar p1 0 (/ l 2))

          p6(polar p5 (/ (* pi 90)180 )(/ w 2))

          )

  (command “pline” p1 p2 p3 p4 p1 “” )

  (setq a(entlast))

  (command “region” a “”)

  (setq b(entlast))

  (command “extrude” b “” h “”)

  (setq c(entlast))

  (command “color” “blue” c)

  (command “cylinder” p6 r h1 “”)

  (setq d(entlast))

  (command “color” “red” d)

  (command “subtract” c “” d “” “”)

  (command “zoom””e”””)

  (command “regen”)

 )

         

 

 

  • Sum4no

  (setq a(getint “Input any value for a:”)

          b(getint “Input any value for b:”)

          c(getint “Input any value for c:”)

          d(getint “Input any value for d:”)

          )

          (setq e (+ a b c d))

              

               

             (print e)

           

 

  • Sum

(setq n(getint “enter number:”))

(setq i 0)

(setq s 0)

 

(while( < i n)

(setq i(+ i 1))

(setq s(+ s i))

(print s)

  )

 

  • Sumabc

(setq a(getint “Enter the value of a:”)

      b(getint “Enter the value of b:”)

      c(getint “Enter the value of c:”)

      )

(setq s(+ a b c))

(print s)

 

  • Nozzle

(defun c:nozzle()

  (command “erase” “all” “”)

  (command “osnap” “off”)

 

  (setq d(getint “enter d:”)

          k(getint “enter k:”)

                   c(getint “enter c:”)

                   d1(getint “enter d1:”)

                   r(getint “enter r:”)

                   h(getint “enter h:”)

                   nd(getint “enter nd:”)

                   b(getint “enter b:”)

                   t1(getint “enter t1:”)

          )

  (setq p1(getpoint”specify first point”)

          p2(polar p1 0 (/ d1 2))

          p3(polar p2 (/ (* pi 90) 180) (* b 2))

          p4(polar p3 0 (- (/ c 2) (/ d1 2)))

          p5(polar p4 (/ (* pi 90) 180) t1)

          p6(polar p5 pi (/ c 2))

          p7(polar p1 0 (- (/ nd 2) r))

          p8(polar p7 (/ (* pi 90) 180) (* 2 b))

          p9(polar p5 pi (- (/ c 2) (/ nd 2)))

          p10(polar p4 0 1)

          p11 (polar p10 0 (/ h 2))

          p12(polar p11 (/(* pi 270)180) b)

          p13 (polar p12 0 (- (/ d 2) (/ k 2)))

          p14(polar p13 (/ (* pi 90)180) b)

          p15(polar p10 (/ (* PI 270)180)1)

          P16(polar p15 pi (- (/ c 2) (/ d1 2)))

          p17(polar p16 (/(* pi 270) (- b 1)))

          )

  (command “line” p1 p2 p3 p4 p5 p6 “”)

  (command “arc” p9 “e” p8 “r” r)

  (command “line” p7 p8 “”)

  (command “line” p10  p14 p13 p17 p16 p15 p10 “”)

  (command “line” p11 p12 “”)

  (setq a1(entlast))

  (command “offset” a1 “” “m” p14 p15)

  ;(command “bhatch” “p” “ansi31” 5 0 h1 )

 (command “mirror” “all” “” p1 p6 “n”)

  (command “zoom” “e”)

  (command “regen”)

  );defun closed

 

  • Tri

(DEFUN C:tri1()

 

(command “erase” “all” “”)

 (command “osnap” “off”)

 

 (SETQ L(getreal “enter length”))

      

  (setq p1 (getpoint “specify p1”)

          p2 (polar p1 0 l)

          p3 (polar p2 (/(* pi 120)180) l)

          p4 (polar p1 0 (/ l 2))

          p5 (polar p2 (/(* pi 120)180) ( / l 2 ))

        p6 (polar p1 (/(* pi 60 )180) ( / l 2 ))

  )

  (command “line” p1 p2 p3 p1 “”)

  (command “circle” “3p” p4 p5 p6)

  (command “circle” “3p” p1 p2 p3)

  (command “zoom” “e” “”)

  (command “regen”)

  

);defunclose

  • Tsec

(defun c:tsec()

  (command “erase” “all” “”)

  (command “osnap” “off”)

  (setq a(getint  “enter the a”)

          b(getint “enter the b:”)

          c(getint “enter the c:”)

          p1(getpoint “specify p1:”)

          p2(polar p1 0 a)

          p3(polar p2 (/(* pi 90)180) (- b a))

          p4(polar p3 0 (- (/ c 2)  (/ a 2)))

          p5(polar p4 (/(* pi 90)180) a)

          p6(polar p5 pi c)

          p7(polar p6 (/(* pi 270)180) a)

          p8(polar p7 0 (- (/ c 2)  (/ a 2)))

          h1(polar p1 (/(* pi 45)180) (/ b 10))

          )

  (commAnd “pline” p1 p2 p3 p4 p5 p6 p7 p8 p1″”)

  (command “bhatch” “p” “ansi31” 6 0 h1 “”)

  (command “zoom” “e”)

  (command “regen” )

  )

     

 

 

         

 

  • Tsef

(defun c:tsec()

(command “erase” “all” “”)

  (command “osnap” “off”)

  (setq a(getint “Enter value of a:”)

          b(getint “Enter value of b:”)

          c(getint “Enter value of c:”)

          d(getint “Enter the value of d:”)

          p1(getpoint “specify  p1:”)

          p2(polar p1 0 a )

          p3(polar p2 (/(* pi 90)180) B)

          p4(polar p3 0 d)

          p5(polar p4 (/(* pi 90)180) a)

          p6(polar p5 pi c)

          p7(polar p6 (/(* pi 270)180) a)

          p8(polar p7 0 d)

          )

  (command “line” p1 p2 p3 p4 p5 p6 p7 p8 p1″”)

  (command “zoom” “E”)

  (command “regen”)

  )

         

 

  • Usec

 

(defun c:Usec()

  (command “erase” “all” “”)

  (command “osnap” “off”)

  (setq l(getint “Enter the length:”)

          w(getint “Enter the width:”)

          R(getint “Enter the radius :”)

          o1(getint “Enter the offset dist:”)

          p1(getpoint “specify p1:”)

          p2(polar p1 (/(* pi 270)180) l)

          p3(polar p2 0 w)

          c1(polar p2 0 (/ w 2))

          p4(polar p3 (/(* pi 90)180) l)

          d1(polar p1 pi o1)

          d2(polar p4 0 o1)

          h1(polar p3 0 1)

          )

  (command “pline” p1 p2 “”)

  (setq l1(entlast))

  (command “pline” p3 p4 “”)

  (setq l2(entlast))

  (command “pline” p1 d1 “”)

  (command “pline” p4 d2 “”)

  (command “arc” p2 “c” c1  p3 )

  (setq a1(entlast))

  (command “offset” o1 l1 d1 “” “”)

  (command “offset” o1 l2 d2 “” “”)

  (command “offset” o1 a1 d1 “” “”)

  (command “bhatch” “p” “ansi31” 3 0 h1 “”)

  (command “zoom” “e”)

  (command “regen”)

  )

 

Advertisements

7 responses to “9 AutoLisp Programming : All Commands

  1. Pingback: 8 AutoLisp Programming : Structure Functions | Mechanical Engineering Online·

  2. Pingback: 7 AutoLisp Programming : Exercise 01 | Mechanical Engineering Online·

  3. Pingback: 6 AutoLisp Programming : Mathematical Functions | Mechanical Engineering Online·

  4. Pingback: 5 AutoLisp Programming : Trignometric Functions | Mechanical Engineering Online·

  5. Pingback: 4 AutoLisp Programming : Arithmetic Functions | Mechanical Engineering Online·

  6. Pingback: 3 AutoLisp Programming : DataTypes | Mechanical Engineering Online·

  7. Pingback: 2 AutoLisp Programming : Basic Knowledge Essentials | Mechanical Engineering Online·

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s