Dayananda Posted July 31, 2022 Posted July 31, 2022 (setq A ( - 2.00 4.00)) (setq B (rtos A)) I want to get it as B= "-2.00" but it display "-2" How can I do this. Quote
Dayananda Posted July 31, 2022 Author Posted July 31, 2022 (edited) 1 hour ago, Isaac26a said: (setq B (rtos A 2 2)) Even (rtos A 2 2) also = "-2" Edited July 31, 2022 by Dayananda Quote
Jamescalabut Posted July 31, 2022 Posted July 31, 2022 Hello, (defun c:fix() (setq mysel (ssget '((0 . "TEXT")))) (setq od (getvar "dimzin")) (setvar "dimzin" 1) (setq number 0) (setq dec (getint "\nnº decimals= ")) (while (setq entity1 (ssname mysel number)) (setq t1 (entget entity1)) (setq text (cdr (assoc 1 t1))) (setq text (vl-string-subst "." "," text)) (setq num (atof text)) (setq num (rtos num 2 dec)) (setq num (vl-string-subst "," "." num)) (setq par (cons 1 num)) (setq t1 (subst par (assoc 1 t1) t1)) (entmod t1) (setq number (1+ number)) ) (setvar "dimzin" od) ) 1 Quote
tombu Posted August 1, 2022 Posted August 1, 2022 I've used this modified snippet from ronjonp for many years as I prefer to avoid modifying dimension variables: (defun Trim0s (xb) ; Thank ronjonp (if (= (type xb) 'real); Trim 0's from end of string conversion, then trim . if it's at the end afterwards. (vl-string-right-trim "." (vl-string-right-trim "0" (vl-princ-to-string xb))) (itoa xb); if integer convert to string without trimming 0's from end. ) ) (trim0s 2.00) returns "2" (trim0s 2.0300) returns "2.03" Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.