Jump to content

Recommended Posts

Posted

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

Posted
(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)
)

 

Posted (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 ?

 

image.png.c0d472b7031626e8d4576f91dee7ec9e.png

 

If its just remove 3rd decimal then easy check strlen and remove.

Edited by BIGAL
Posted

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 😒

Posted (edited)

Post a sample dwg. Sounds like the point is not being read correctly.

Edited by BIGAL
Posted (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 by Tharwat
Ignorant deserves voids
Posted

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.

Posted
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?

Posted
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)

 

Posted
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 .

Posted (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)

 

 

IMG-20200112-WA0007.jpeg

Edited by pmadhwal7
Posted
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 ...

Posted (edited)
34 minutes ago, pmadhwal7 said:

IMG-20200112-WA0007.jpeg

 

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 by Lee Mac
Posted
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.....

 

Posted
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.

Posted

Here is a list of elevations from the latest survey I am processing. It shows the random nature of the third decimal place.

 

 

survey elevations.PNG

Posted (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 by BIGAL
Posted
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.

 

 

survey elevations.PNG

 

Posted
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.....

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...