这是一个更新版本需要getvals3。lsp
- ; Formula as text .lsp
- ; By Alan H July 2017
- (defun mathtxt ( / num1 num2 val1 val2 val3)
- (setq decpl 2)
- (if (not Ah:getval3)(load "getvals3"))
- (ah:getval3 "1st number " 5 4 "1" "2nd number " 8 7 "2" "Math operation + - / *" 6 4 "X")
- (setq num1 (atof val1))
- (setq num2 (atof val2))
- (if (= (strcase val3) "X") (setq ans (strcat val1 " " val3 " " val2 " = " (rtos (* num1 num2) 2 decpl ))))
- (if (= val3 "-")(setq ans (strcat val1 " " val3 " " val2 " = " (rtos (- num1 num2) 2 decpl ))))
- (if (= val3 "+")(setq ans (strcat val1 " " val3 " " val2 " = " (rtos (+ num1 num2) 2 decpl ))))
- (if (= val3 "/")(setq ans (strcat val1 " " val3 " " val2 " = " (rtos (/ num1 num2) 2 decpl ))))
- (command "Text" (getpoint) "" ans) ; text with preset height
- ;(command "Text" (getpoint) "" "" ans) ;text with no height set
- (mathtxt)
|