Something like this?
Code:(strcat (if (> MyRealValue 0) "+" "") (rtos MyRealValue 2 3) "m")
Registered forum members do not see this ad.
Hai Dudes,
I have been looking for a code that will set the decimals to 3 and add a prefix "+" to all positive values and "m" as suffix for all the selected text.
ex. -3
-3.002
5.01
5.005
the output should be
-3.000m
-3.002m
+5.010m
+5.005m
Thanks for your help in advance.
Something like this?
Code:(strcat (if (> MyRealValue 0) "+" "") (rtos MyRealValue 2 3) "m")
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3
Check this out .....
Code:(defun c:Test (/ ss i sn str e) (vl-load-com) ;;; Tharwat 08. May. 2012 ;;; (if (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT")))) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (if (and (not (eq 45 (nth 0 (vl-string->list (setq str (cdr (assoc 1 (setq e (entget sn))))) ) ) ) ) (numberp (read str)) ) (entmod (subst (cons 1 (strcat "+" (rtos (read str) 2 3) "m")) (assoc 1 e) e ) ) ) ) (princ) ) (princ) )
- When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said
I forgot to change the decimal values of minus values , so try this if it is better for you...
Code:(defun c:Test (/ ss i sn str e) (vl-load-com) ;;; Tharwat 08. May. 2012 ;;; (if (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT")))) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (setq str (cdr (assoc 1 (setq e (entget sn))))) (cond ((and (not (eq 45 (nth 0 (vl-string->list str ) ) ) ) (numberp (read str)) ) (entmod (subst (cons 1 (strcat "+" (rtos (read str) 2 3) "m")) (assoc 1 e) e ) ) ) ((and (eq 45 (nth 0 (vl-string->list str))) (numberp (read str)) ) (entmod (subst (cons 1 (rtos (read str) 2 3)) (assoc 1 e) e ) ) ) ) ) (princ) ) (princ) )
- When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said
My version:
Code:(defun c:fixtxt ( / d e i s x ) ;; Lee Mac 2012 (setq d (getvar 'dimzin)) (setvar 'dimzin 0) (if (setq s (ssget "_:L" '((0 . "TEXT,MTEXT") (1 . "*#*")))) (repeat (setq i (sslength s)) (setq e (entget (ssname s (setq i (1- i))))) (if (setq x (distof (cdr (assoc 1 e)))) (setq x (strcat (if (< 0 x) "+" "") (rtos x 2 3) "m") e (entmod (subst (cons 1 x) (assoc 1 e) e)) ) ) ) ) (setvar 'dimzin d) (princ) )
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
Registered forum members do not see this ad.
Thanks lee and sorry for the delay. I just get very little access to internet during office hours.
This is all my requirements,
Thanks to all for their efforts and contributions
Bookmarks