Lisp Debug help...

Discussion in 'AutoCAD' started by jongor, Jan 13, 2005.

  1. jongor

    jongor Guest

    Would someone be so kind as to review my lisp routine?

    It's supposed to draw terminal blocks and label them sequentially.

    I keep getting a syntax error, but can't figure out what I did wrong.

    See any glaring errors?

    Thanks.....

    (defun DTR (a)
    (* PI (/ a 180.0)))

    (defun c:tb (/ n1 n2 n3 p1 p1x p1y p2 p3 p4 t1 layr)

    (setvar "cmdecho" 1)

    (setq savemode1 (getvar "osmode"))
    (setvar "osmode" 0)
    (setvar "filedia" 0); turn off dialog boxes

    (setq layr (getvar "clayer")); get current layer before terminal construction

    ;create layers for terminal block
    (command "layer" "m" "equip" "c" "5" "" "")
    (command "layer" "m" "text" "c" "3" "" "")
    (command "layer" "m" "wiring" "c" "1" "" "")

    (setq n1a (getstring"\How many terminals? :"));get the number of terminals needed
    ;(setq n1 (getint"\How many terminals? :"));get the number of terminals needed
    (setq n1 (atoi n1a));Convert string to integer
    (setq n2 (* n1 0.25)) ;length of terminal strip
    (setq n1b (+ 2 n1)) ;number of terminal lines

    (setq p1 (getpoint "\nSelect start position of terminal block :"))
    (setq p5 p1)
    (setq p2 (polar p1 (DTR 0) 1))
    (setq p3 (polar p2 (DTR 270) n2))
    (setq p4 (polar p1 (DTR 270) n2))

    (command "clayer" "equip") ;change current layer to equip

    (command "line" p1 p4 "")
    (command "line" p2 p3 "")

    (setq count 1)
    (while (< count n1b)
    (command "line" p1 p2 "")
    (setq p1 (polar p1 (dtr 270) 0.25))
    (setq p2 (polar p2 (dtr 270) 0.25))
    (setq count (+ 1 count)))


    (command "clayer" "text");change current layer to text
    (command "textsize" "3/32" "")

    (setq t1 (polar p5 (DTR 0) 0.5))
    (setq t2 (polar t1 (DTR 270) 0.125))

    (setq count 1)
    (while (< count n1))
    (princ count)
    (setq n3 (atoi count))
    (command "dtext" "m" t2 "" "0" n3)
    (setq t2 (polar t2 (dtr 270) 0.125))
    (setq count (+ 1 count))
    )

    (command "clayer" layr)); set layer back to original
    (princ "\n ")
    (princ)
    )
     
    jongor, Jan 13, 2005
    #1
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.