pmadhwal7 Posted January 11, 2020 Posted January 11, 2020 Dear all sir I have nearly thousands of elevation Text placed in AutoCAD and one wrong thing happened after decimal 2 digit are ok but the thrid digit are coming "0", like 340.430, 345.550 and the project requirement is third digit should not be zero how can i remove zero and add some numbers as i have too many text in my dwg Quote
Lee Mac Posted January 11, 2020 Posted January 11, 2020 (defun c:test ( / i s v x ) (if (setq s (ssget "_:L" '((0 . "TEXT,MTEXT") (1 . "~*[~-.0-9]*") (1 . "*.*0")))) (repeat (setq i (sslength s)) (setq i (1- i) x (entget (ssname s i)) v (assoc 1 x) ) (entmod (subst (cons 1 (vl-string-right-trim "0" (cdr v))) v x)) ) ) (princ) ) Quote
BIGAL Posted January 12, 2020 Posted January 12, 2020 (edited) Lee I think he wants 2 decimals not 3. This has been answered I think by you to convert , need padding etc in image left is original text, middle your routine right changed to do atof then rtos. As can be seen a bit unpredictable. Need OP to confirm.What about rounding or is it always 0 ? If its just remove 3rd decimal then easy check strlen and remove. Edited January 12, 2020 by BIGAL Quote
pmadhwal7 Posted January 12, 2020 Author Posted January 12, 2020 Sorry bigal Sir but i didn't want to remove thrid decimal i want to replace 0 with 1-9 any value like if i have 2.120 then i need to 2.124 means last value should not be 0 it should be 1-9 any value hope you understand my words little weak in English Quote
BIGAL Posted January 12, 2020 Posted January 12, 2020 (edited) Post a sample dwg. Sounds like the point is not being read correctly. Edited January 12, 2020 by BIGAL Quote
Tharwat Posted January 12, 2020 Posted January 12, 2020 (edited) 11 hours ago, pmadhwal7 said: Sorry bigal Sir but i didn't want to remove thrid decimal i want to replace 0 with 1-9 any value like if i have 2.120 then i need to 2.124 means last value should not be 0 it should be 1-9 any value hope you understand my words little weak in English Something like this? Edited January 12, 2020 by Tharwat Ignorant deserves voids Quote
eldon Posted January 12, 2020 Posted January 12, 2020 I have come across this before where the client is dimension blind, and thinks that three decimal places in the elevation MUST be more accurate than two!!! So what you need to do is adjust the current text to three places of decimals, by adding ( or subtracting) a random value between -0.005 to +0.004 to each elevation so that when rounded to two places it gets back to what it is at present. If you add 0.001 to 0.009, then some of the values would be rounded up 0.01 when returned to two decimal places. Quote
dlanorh Posted January 12, 2020 Posted January 12, 2020 18 hours ago, pmadhwal7 said: Dear all sir I have nearly thousands of elevation Text placed in AutoCAD and one wrong thing happened after decimal 2 digit are ok but the thrid digit are coming "0", like 340.430, 345.550 and the project requirement is third digit should not be zero how can i remove zero and add some numbers as i have too many text in my dwg What Layer(s) are the text entities on? Are they all Text or a mixture of Text and MText? Quote
Lee Mac Posted January 12, 2020 Posted January 12, 2020 2 hours ago, eldon said: I have come across this before where the client is dimension blind, and thinks that three decimal places in the elevation MUST be more accurate than two!!! So what you need to do is adjust the current text to three places of decimals, by adding ( or subtracting) a random value between -0.005 to +0.004 to each elevation so that when rounded to two places it gets back to what it is at present. If you add 0.001 to 0.009, then some of the values would be rounded up 0.01 when returned to two decimal places. This seems like a really daft thing to do, but - (defun c:test ( / i s v x ) (if (setq s (ssget "_:L" '((0 . "TEXT,MTEXT") (1 . "~*[~-.0-9]*") (1 . "*.##0")))) (repeat (setq i (sslength s)) (setq i (1- i) x (entget (ssname s i)) v (assoc 1 x) ) (entmod (subst (cons 1 (rtos (+ (atof (cdr v)) (* (LM:rand) 0.009) -0.005) 2 3)) v x)) ) ) (princ) ) ;; Rand - Lee Mac ;; PRNG implementing a linear congruential generator with ;; parameters derived from the book 'Numerical Recipes' (defun LM:rand ( / a c m ) (setq m 4294967296.0 a 1664525.0 c 1013904223.0 $xn (rem (+ c (* a (cond ($xn) ((getvar 'date))))) m) ) (/ $xn m) ) (princ) Quote
Ish Posted January 12, 2020 Posted January 12, 2020 8 hours ago, pmadhwal7 said: Sorry bigal Sir but i didn't want to remove thrid decimal i want to replace 0 with 1-9 any value like if i have 2.120 then i need to 2.124 means last value should not be 0 it should be 1-9 any value hope you understand my words little weak in English better to use excel. export all text in excel and modify that by formula or other trick, then import to cad . Quote
pmadhwal7 Posted January 12, 2020 Author Posted January 12, 2020 (edited) 46 minutes ago, Lee Mac said: Yes sirrr very useful... thanks i will try it once and will try again... thanks but it was removed my 2nd digit and place new digit check the screenshot Quote This seems like a really daft thing to do, but - (defun c:test ( / i s v x ) (if (setq s (ssget "_:L" '((0 . "TEXT,MTEXT") (1 . "~*[~-.0-9]*") (1 . "*.##0")))) (repeat (setq i (sslength s)) (setq i (1- i) x (entget (ssname s i)) v (assoc 1 x) ) (entmod (subst (cons 1 (rtos (+ (atof (cdr v)) (* (LM:rand) 0.009) -0.005) 2 3)) v x)) ) ) (princ) ) ;; Rand - Lee Mac ;; PRNG implementing a linear congruential generator with ;; parameters derived from the book 'Numerical Recipes' (defun LM:rand ( / a c m ) (setq m 4294967296.0 a 1664525.0 c 1013904223.0 $xn (rem (+ c (* a (cond ($xn) ((getvar 'date))))) m) ) (/ $xn m) ) (princ) Edited January 12, 2020 by pmadhwal7 Quote
pmadhwal7 Posted January 12, 2020 Author Posted January 12, 2020 38 minutes ago, Ish said: better to use excel. export all text in excel and modify that by formula or other trick, then import to cad . Any Excel formula u remember ... Quote
pmadhwal7 Posted January 12, 2020 Author Posted January 12, 2020 please check sample file sample.dwg Quote
Lee Mac Posted January 12, 2020 Posted January 12, 2020 (edited) 34 minutes ago, pmadhwal7 said: Yes, the program performs exactly as @eldon has described - the resulting values will always round to the original when rounded to 2 decimal places. If you strictly require the second digit to remain unchanged, and also avoid the value being rounded up to the next hundreth, you could change this line: (entmod (subst (cons 1 (rtos (+ (atof (cdr v)) (* (LM:rand) 0.009) -0.005) 2 3)) v x)) To: (entmod (subst (cons 1 (rtos (+ (atof (cdr v)) (* (LM:rand) 0.0045)) 2 3)) v x)) Edited January 12, 2020 by Lee Mac Quote
pmadhwal7 Posted January 12, 2020 Author Posted January 12, 2020 6 minutes ago, Lee Mac said: Yes, the program performs exactly as @eldon has described - the resulting values will always round to the original when rounded to 2 decimal places. If you strictly require the second digit to remain unchanged, and also avoid the value being rounded up to the next hundreth, you could change this line: (entmod (subst (cons 1 (rtos (+ (atof (cdr v)) (* (LM:rand) 0.009) -0.005) 2 3)) v x)) To: (entmod (subst (cons 1 (rtos (+ (atof (cdr v)) (* (LM:rand) 0.0045)) 2 3)) v x)) Thanks a lot this is working fine i will try it to main file..... Quote
eldon Posted January 12, 2020 Posted January 12, 2020 1 hour ago, Lee Mac said: This seems like a really daft thing to do, but - .... If the original survey data (I am assuming this to be a topographical survey drawing) were to be available, then this whole furore would be unnecessary. But if that is not the case, then the least damage that is done to the existing data is good. Quote
eldon Posted January 12, 2020 Posted January 12, 2020 Here is a list of elevations from the latest survey I am processing. It shows the random nature of the third decimal place. Quote
BIGAL Posted January 12, 2020 Posted January 12, 2020 (edited) Like Eldon does not make any sense if you want less decimals then standard practice is to round up or down. Civil Engineer since 1978. The correct answer is go back to the 3d points and re label. Ps when reducing say a total station data it will produce results in excess of 3 decimals but displayed say as 3. Edited January 12, 2020 by BIGAL Quote
pmadhwal7 Posted January 13, 2020 Author Posted January 13, 2020 11 hours ago, eldon said: yes sir u r right but their is different problem actually we manipulated all the data and and now manager say third decimal should not be 0 and their is thousand of elevation we have so if we rework it will take 3-4 days and we didn't have time that's y i ask... Here is a list of elevations from the latest survey I am processing. It shows the random nature of the third decimal place. Quote
pmadhwal7 Posted January 13, 2020 Author Posted January 13, 2020 12 hours ago, Lee Mac said: Yes, the program performs exactly as @eldon has described - the resulting values will always round to the original when rounded to 2 decimal places. If you strictly require the second digit to remain unchanged, and also avoid the value being rounded up to the next hundreth, you could change this line: (entmod (subst (cons 1 (rtos (+ (atof (cdr v)) (* (LM:rand) 0.009) -0.005) 2 3)) v x)) To: (entmod (subst (cons 1 (rtos (+ (atof (cdr v)) (* (LM:rand) 0.0045)) 2 3)) v x)) many thanks it works fine..... 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.