It is funny with alert

Discussion in 'AutoCAD' started by Adesu, Jul 29, 2004.

  1. Adesu

    Adesu Guest

    If user wrong type of bolt (M30 or M3),the alert will displayed and follow
    it with "ENTER LENGTH OF BOLT",and user type of bolt true (M4 to M24),the
    "alert" displayed again,why this ? can somebody help me to solve this
    wrong,thanks a lot.
    Best regards
    Ade Suharna

    ; Design by Ade Suharna
    ; 23 July 2004
    ; Edit by Ade Suharna 29/07/2004 1).
    ;----------------------------------------------------
    (defun dtr (a)
    (* pi (/ a 180.0)))
    (defun c:lb ()
    (setq oldosmode (getvar "osmode")) ; get osmode setting
    (setvar "osmode" 0) ; osmode set to 0
    (setq oldcmdecho (getvar "cmdecho")) ; get cmdecho setting
    (setvar "cmdecho" 0) ; cmdecho set to 0
    (vl-load-com)
    ;----------------------------------------------------
    (setq list_m4 '(7.0 6.5 4.0 3.0 2.4) ; data
    dimension
    list_m5 '(8.5 8.0 5.0 4.0 3.1) ; D,d,H,W and s
    list_m6 '(10.0 9.5 6.0 5.0 3.78) ; D = head diameter
    list_m8 '(13.0 12.5 8.0 6.0 4.78) ; d = head dia cham
    list_m10 '(16.0 15.5 10.0 8.0 6.25) ; H = head height
    list_m12 '(18.0 17.5 12.0 10.0 7.5) ; W = polygon
    dimension
    list_m14 '(21.0 20.5 14.0 12.0 8.6) ; s = depth of polygon
    list_m16 '(24.0 23.5 16.0 14.0 9.7)
    list_m20 '(30.0 29.5 20.0 17.0 11.8)
    list_m24 '(36.0 35.5 24.0 19.0 14.0))
    ;----------------------------------------------------
    (setq loc (getpoint "\nCLICK LOCATION FOR OBJECT:"))
    (prompt "\ M4 M5 M6 M8 M10 M12 M14 M16 M20 M24")
    (setq typ (strcase (getstring "\nSELECT TYPE OF BOLT : " T)))
    ; 1).
    (if (/= typ name)(alert (strcat "\nYOUR CHOOSE IS WRONG
    \nPlease try again,choose one
    \nM4 M5 M6 M8 M10 M12 M14 M16 M20 M24"))
    ; 1).
    (exit)
    ) ; end of if
    (setq bolt
    (cond ((= typ "M4")(setq lpm4 list_m4))
    ((= typ "M5")(setq lpm5 list_m5))
    ((= typ "M6")(setq lpm6 list_m6))
    ((= typ "M8")(setq lpm8 list_m8))
    ((= typ "M10")(setq lpm10 list_m10))
    ((= typ "M12")(setq lpm12 list_m12))
    ((= typ "M14")(setq lpm14 list_m14))
    ((= typ "M16")(setq lpm16 list_m16))
    ((= typ "M20")(setq lpm20 list_m20))
    ((= typ "M24")(setq lpm24 list_m24))
    ) ; end of cond
    ) ; end of setq
    (setq len (getdist "\nENTER LENGTH OF BOLT:"))
    ;----------------------------------------------------
    (head1)
    (head2)
    (command "_text" "j" "ml"
    (list (car loc)(- (cadr loc)(nth 0 bolt)))
    (nth 4 bolt) "0" typ)
    ;----------------------------------------------------
    (setvar "osmode" oldosmode) ; return setting
    (setvar "cmdecho" oldcmdecho) ; return setting
    (princ)
    (command "_redraw")
    ) ; end of program
    ;----------------------------------------------------
    (defun head1 () ; draw of head
    (setq dhea (nth 0 bolt) ; set for diameter
    head outter
    ihea (nth 1 bolt) ; set for diameter head inner
    ; (after chamfer)
    ihea1 (/ ihea 2.0)
    wpol (nth 3 bolt) ; set for width of polygon
    wpol1 (/ wpol 2.0)
    hhea (nth 2 bolt) ; set for height of head
    hhea1 (/ hhea 2.0)
    dhea1 (/ dhea 2.0)
    dhea2 (+ dhea1 2.0)
    ct1 (polar loc (dtr 180) dhea2)
    ct2 (polar loc (dtr 0) dhea2)
    ct3 (polar loc (dtr 90) dhea2)
    ct4 (polar loc (dtr 270) dhea2))
    (command "_circle" loc dhea1 ""
    "_circle" loc ihea1 "")
    (command "_polygon" 6 loc "C" wpol1 ""
    "_line" ct1 ct2 ""
    "_line" ct3 ct4 "")
    ) ; end of defun
    ;----------------------------------------------------
    (defun head2 () ; draw of head
    (setq loc1 (polar loc 0 dhea)
    loc2 (polar loc1 (dtr 45) 2.0)
    c0 (* (* (nth 2 bolt) 0.1118)
    (sin (dtr 26.57)))
    c1 63.43
    c2 116.57
    cl1 (* (nth 2 bolt) 0.1118)
    cl2 (* (nth 2 bolt) 0.8)
    lim (* len 0.1)
    lim1 (- len lim c0 c0)
    ct5 (polar loc1 (dtr 180) 2.0)
    ct6 (polar ct5 (dtr 0)(+ hhea len 4.0))
    p1 (polar loc1 (dtr 270) ihea1)
    p2 (polar p1 (dtr 324.74) 0.443)
    p3 (polar p2 (dtr 0)(- hhea c0))
    p4 (polar p3 (dtr 90) dhea)
    p5 (polar p4 (dtr 180)(- hhea c0))
    p6 (polar p5 (dtr 215.2) 0.443)
    p7 (polar p3 (dtr 90)(- dhea1 hhea1))
    p8 (polar p7 (dtr 0)(- len c0))
    p9 (polar p8 (dtr c1) cl1)
    p10 (polar p9 (dtr 90) cl2)
    p11 (polar p10 (dtr c2) cl1)
    p12 (polar p11 (dtr 180)(- len c0))
    p13 (polar p7 (dtr 0) lim)
    p14 (polar p13 (dtr c1) cl1)
    p15 (polar p14 (dtr 90) cl2)
    p16 (polar p15 (dtr c2) cl1)
    p17 (polar p14 (dtr 0) lim1)
    p18 (polar p15 (dtr 0) lim1))
    (command "_pline" loc1 p1 p2 p3 p4 p5 p6 "c" ""
    "_pline" p7 p8 p9 p10 p11 p12 "c" ""
    "_pline" p13 p14 p15 p16 "c" ""
    "_line" p8 p11 ""
    "_line" p14 p17 ""
    "_line" p15 p18 ""
    "_line" p2 p5 ""
    "_line" ct5 ct6 "")
    (command "_bhatch" "p" "ansi31" 10 0 loc2 "")
    ) ; end of defun
     
    Adesu, Jul 29, 2004
    #1
  2. Adesu

    Jürg Menzi Guest

    Hi Ade

    No more comments - check the modifications and learn from.

    Code:
    ;    Design by Ade Suharna
    ;    23 July 2004
    ;    Edit by Ade Suharna 29/07/2004      1).
    ;----------------------------------------------------
    (defun dtr (a)
    (* pi (/ a 180.0))
    )
    
    ;----------------------------------------------------
    (defun c:lb ( / oldosmode oldcmdecho list_m4 list_m5 list_m6 list_m8 list_m10
    list_m12 list_m14 list_m16 list_m20 list_m24 InsPnt TmpPmt
    TmpTyp BltDat TmpLen dhea dhea1 hhea hhea1 ihea1)
    (setq oldosmode  (getvar "OSMODE")			; get osmode setting
    oldcmdecho (getvar "CMDECHO")			; get cmdecho setting
    )
    (setq BltLst (list
    (cons "M4"  '(7.0 6.5 4.0 3.0 2.4))	; data dimension
    (cons "M5"  '(8.5 8.0 5.0 4.0 3.1))	; D,d,H,W and s
    (cons "M6"  '(10.0 9.5 6.0 5.0 3.78))	; D = head diameter
    (cons "M8"  '(13.0 12.5 8.0 6.0 4.78))	; d = head dia cham
    (cons "M10" '(16.0 15.5 10.0 8.0 6.25))	; H = head height
    (cons "M12" '(18.0 17.5 12.0 10.0 7.5))	; W = polygon dimension
    (cons "M14" '(21.0 20.5 14.0 12.0 8.6))	; s = depth of polygon
    (cons "M16" '(24.0 23.5 16.0 14.0 9.7))
    (cons "M20" '(30.0 29.5 20.0 17.0 11.8))
    (cons "M24" '(36.0 35.5 24.0 19.0 14.0))
    )
    InsPnt (getpoint "\nClick location for object: ")
    )
    (if InsPnt
    (progn
    (initget "M4 M5 M6 M8 M10 M12 M14 M16 M20 M24")
    (setq GloTyp (cond (GloTyp) ("M10"))
    TmpPmt "\nSelect Bolt Type [M4/M5/M6/M8/M10/M12/M14/M16/M20/M24]"
    TmpTyp (getkword (strcat TmpPmt " <" GloTyp ">: "))
    GloTyp (cond (TmpTyp) (GloTyp))
    BltDat (cdr (assoc GloTyp BltLst))
    GloLen (cond (GloLen) (30.0))
    )
    (initget 6)
    (setq TmpPmt "\nEnter length of bolt"
    TmpLen (getdist (strcat TmpPmt " <" (rtos GloLen) ">: "))
    GloLen (cond (TmpLen) (GloLen))
    )
    (setvar "CMDECHO" 0)					; cmdecho set to 0
    (setvar "OSMODE" 0)					; osmode set to 0
    (head1)
    (head2)
    (command "_TEXT" "_JU" "_ML"
    (list (car InsPnt) (- (cadr InsPnt) (nth 0 BltDat)))
    (nth 4 BltDat) 0 GloTyp
    )
    (redraw)
    (setvar "OSMODE" oldosmode)				; return setting
    (setvar "CMDECHO" oldcmdecho)			; return setting
    )
    )
    (princ)
    ); end of program
    
    ;----------------------------------------------------
    ; draw of head
    (defun head1 ( / ihea wpol wpol1 dhea2 ct1 ct2 ct3 ct4)
    (setq dhea  (nth 0 BltDat)				; set for diameter
    ihea  (nth 1 BltDat)				; set for diameter head
    ; inner (after chamfer)
    ihea1 (/ ihea 2.0)
    wpol  (nth 3 BltDat)				; set for width of polygon
    wpol1 (/ wpol 2.0)
    hhea  (nth 2 BltDat)				; set for height of head
    hhea1 (/ hhea 2.0)
    dhea1 (/ dhea 2.0)
    dhea2 (+ dhea1 2.0)
    ct1   (polar InsPnt (dtr 180) dhea2)
    ct2   (polar InsPnt (dtr 0) dhea2)
    ct3   (polar InsPnt (dtr 90) dhea2)
    ct4   (polar InsPnt (dtr 270) dhea2)
    )
    (command "_CIRCLE" InsPnt dhea1
    "_CIRCLE" InsPnt ihea1
    "_POLYGON" 6 InsPnt "_CI" wpol1
    "_LINE" ct1 ct2 ""
    "_LINE" ct3 ct4 ""
    )
    ); end of defun
    
    ;----------------------------------------------------
    ; draw of head
    (defun head2 ( / loc1 loc2 c0 c1 c2 cl1 cl2 lim lim1 ct5 ct6 p1 p2 p3 p4 p5 p6
    p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 ss)
    (setq loc1 (polar InsPnt 0 dhea)
    loc2 (polar loc1 (dtr 45) 2.0)
    c0   (* (* (nth 2 BltDat) 0.1118) (sin (dtr 26.57)))
    c1   63.43
    c2   116.57
    cl1  (* (nth 2 BltDat) 0.1118)
    cl2  (* (nth 2 BltDat) 0.8)
    lim  (* GloLen 0.1)
    lim1 (- GloLen lim c0 c0)
    ct5  (polar loc1 (dtr 180) 2.0)
    ct6  (polar ct5 (dtr 0)(+ hhea GloLen 4.0))
    p1   (polar loc1 (dtr 270) ihea1)
    p2   (polar p1 (dtr 324.74) 0.443)
    p3   (polar p2 (dtr 0)(- hhea c0))
    p4   (polar p3 (dtr 90) dhea)
    p5   (polar p4 (dtr 180)(- hhea c0))
    p6   (polar p5 (dtr 215.2) 0.443)
    p7   (polar p3 (dtr 90)(- dhea1 hhea1))
    p8   (polar p7 (dtr 0)(- GloLen c0))
    p9   (polar p8 (dtr c1) cl1)
    p10  (polar p9 (dtr 90) cl2)
    p11  (polar p10 (dtr c2) cl1)
    p12  (polar p11 (dtr 180)(- GloLen c0))
    p13  (polar p7 (dtr 0) lim)
    p14  (polar p13 (dtr c1) cl1)
    p15  (polar p14 (dtr 90) cl2)
    p16  (polar p15 (dtr c2) cl1)
    p17  (polar p14 (dtr 0) lim1)
    p18  (polar p15 (dtr 0) lim1)
    ss   (ssadd)
    )
    (command "_PLINE" loc1 p1 p2 p3 p4 p5 p6 "_CL")
    (ssadd (entlast) ss)
    (command "_PLINE" p7 p8 p9 p10 p11 p12 "_CL")
    (ssadd (entlast) ss)
    (command "_PLINE" p13 p14 p15 p16 "_CL"
    "_LINE" p8 p11 ""
    "_LINE" p14 p17 ""
    "_LINE" p15 p18 ""
    "_LINE" p2 p5 ""
    "_LINE" ct5 ct6 ""
    "_BHATCH" "_PR" "ANSI31" 1 0 "_SE" ss "" ""
    )
    ); end of defun
    
    Cheers
     
    Jürg Menzi, Jul 29, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.