This is still going to have the problems described in my earlier replies:
1. Backslashes are for user input in macro format, but not inside a lisp
function. Use pause instead.
2. The com_dtext function is going to fail under some justifications
because the pauses won't be in the right places or the right quantity.
3. If all justifications call up the same function, there's little point in
checking which justification was entered, with all those (if) functions. If
you just want to know whether they entered a valid justification, try
(member) instead, with the justifications all in a single list.
--
Kent Cooper
"Adesu" wrote...
Hi Erik,
Your code I just revised,in order to more simple,look like this,and how
comment you.
[code]
(defun com_dtext ()
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(defun c:dt (/ *error* cl cmdecho ct err lisp-err newlayer tjust tm tsize
tstyl vs)
(setvar "cmdecho" 0)
(setq err *error*)
(setq *error* lisp-err)
(setq cmdecho 0)
(setq cl (getvar "clayer"))
(setq ct (getvar "ctab"))
(setq tstyl (getvar "textstyle"))
(setvar "textstyle" "simplex")
(setq newlayer (strcat "text" (substr ct 1 3)))
;---------------------------------------------
(setq tm (getvar "tilemode"))
(if
(= tm 1)
(setvar "tilemode" 0)
) ; if
;---------------------------------------------
(command "vplayer" "n" newlayer "")
(command "vplayer" "t" newlayer "c" "")
(command "-layer" "m" newlayer "c" "130" "" "")
(setq vs (/ 1 (caddr (trans '(0 0 1) 2 3))))
(setq tsize (* vs 0.125))
(setq tjust
(getstring
"\nenter a justification option
[align/fit/center/middle/left/right/tl/tc/tr/ml/mc/mr/bl/bc/br]
:"))
(setvar "cmdecho" 1)
(if (= tjust "a")(com_dtext))
(if (= tjust "f")(com_dtext))
(if (= tjust "c")(com_dtext))
(if (= tjust "m")(com_dtext))
(if (= tjust "l")(com_dtext))
(if (= tjust "r")(com_dtext))
(if (= tjust "tl")(com_dtext))
(if (= tjust "tc")(com_dtext))
(if (= tjust "tr")(com_dtext))
(if (= tjust "ml")(com_dtext))
(if (= tjust "mc")(com_dtext))
(if (= tjust "mr")(com_dtext))
(if (= tjust "bl")(com_dtext))
(if (= tjust "bc")(com_dtext))
(if (= tjust "br")(com_dtext))
(setvar "clayer" cl)
(setvar "textstyle" tstyl)
(princ)
)
(defun lisp-err (msg)
(if
(/= msg "function cancelled")
(princ (strcat "\nerror: " msg))
) ;_ end of if
(setvar "clayer" cl)
(princ)
) ;_ end of defun
[/code]
"Erik Deyo" wrote in message
news:5374312@discussion.autodesk.com...
The following lisp will prompt me for rotation but then just dies. Can
someone see what I'm missing?
Thanks
(DEFUN C:dt ()
(SETVAR "CMDECHO" 0)
(setq
ERR *ERROR*
*ERROR* LISP-ERR
CMDECHO 0
)
(SETQ CL (GETVAR "CLAYER"))
(setq ct (getvar "ctab"))
(setq tstyl (getvar "textstyle"))
(setvar "textstyle" "simplex")
(setq NewLayer (strcat "TEXT" (substr CT 1 3)))
(COMMAND "VPLAYER" "N" NEWLAYER "")
(COMMAND "VPLAYER" "T" NEWLAYER "C" "")
(COMMAND "-LAYER" "M" NewLayer "C" "130" "" "")
(SETQ VS (/ 1 (caddr (trans '(0 0 1) 2 3))))
(setq tsize (* VS 0.125))
(setq TJUST
(getSTRING
"\nEnter a justification option
[Align/Fit/Center/Middle/Left/Right/TL/TC/TR/ML/MC/MR/BL/BC/BR] :"
)
)
(SETVAR "CMDECHO" 1)
(IF (= tjust "A")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(IF (= tjust "F")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(IF (= tjust "C")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(IF (= tjust "M")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(IF (= tjust "L")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(IF (= tjust "R")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(IF (= tjust "TL")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(IF (= tjust "TC")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(IF (= tjust "TR")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(IF (= tjust "ML")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(IF (= tjust "MC")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(IF (= tjust "MR")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(IF (= tjust "BL")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(IF (= tjust "BC")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(IF (= tjust "BR")
(command "_dtext" "j" tjust "\\" tsize "\\" "\\")
)
(SETVAR "CLAYER" CL)
(setvar "textstyle" tstyl)
(PRINC)
)
(defun
LISP-ERR
(MSG)
(if (/= MSG "Function cancelled")
(princ (strcat "\nError: " MSG))
) ;_ end of if
(setvar "CLAYER" CL)
(princ)
) ;_ end of defun
--
Erik D.
CAD Manager
Atkinson Industries, Inc.
620-231-6900