How influence to program

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

  1. Adesu

    Adesu Guest

    Hi Alls,can you inform to me ,how influence to program if ;

    (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)
    bla.. bla...bla
    )

    Compare to

    (defun c:lb ( )
    bla.. bla...bla
    )


    ;---------------------------------------------------------------------------
    ------------------------------

    ; Design by Ade Suharna
    ; 23 July 2004
    ; Edit by Ade Suharna 29/07/2004 1).
    ; Juerg Menzi 30/07/2004 2).
    ; (http://www.menziengineering.ch)

    ;----------------------------------------------------
    (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 2).
    (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
    2).
    (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)
    2).
    )
    (command "_PLINE" loc1 p1 p2 p3 p4 p5 p6 "_CL")
    (ssadd (entlast) ss)
    2).
    (command "_PLINE" p7 p8 p9 p10 p11 p12 "_CL")
    (ssadd (entlast) ss)
    2).
    (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 "" "" 2).
    )
    ) ; end of defun
     
    Adesu, Jul 30, 2004
    #1
  2. Adesu

    MP Guest

    placing variable names after the / in the argument list sets them to nil
    when program ends

    (defun test()
    (setq var1 1)
    )

    (test)
    !var1
    1

    (defun test( / var1)
    (setq var1 1)
    )

    (test)
    !var1
    nil

     
    MP, Jul 30, 2004
    #2
  3. Adesu

    Adesu Guest

    Hi MP,your comment clear , good and easy to understood,thanks a lot

     
    Adesu, Aug 23, 2004
    #3
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.