CADWORKER Posted April 26, 2012 Share Posted April 26, 2012 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. Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 26, 2012 Share Posted April 26, 2012 Something like this? (strcat (if (> MyRealValue 0) "+" "") (rtos MyRealValue 2 3) "m") Quote Link to comment Share on other sites More sharing options...
CADWORKER Posted May 8, 2012 Author Share Posted May 8, 2012 Something like this? (strcat (if (> MyRealValue 0) "+" "") (rtos MyRealValue 2 3) "m") Iam new to coding so if anyone can write a small lisp for this. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 8, 2012 Share Posted May 8, 2012 Check this out ..... (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) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 8, 2012 Share Posted May 8, 2012 I forgot to change the decimal values of minus values , so try this if it is better for you... (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) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 8, 2012 Share Posted May 8, 2012 My version: (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) ) Quote Link to comment Share on other sites More sharing options...
CADWORKER Posted May 10, 2012 Author Share Posted May 10, 2012 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 Quote Link to comment Share on other sites More sharing options...
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.