Subtract numerically from text

Subtract numerically from text

jrobinsonTZZT2
Observer Observer
629 Views
7 Replies
Message 1 of 8

Subtract numerically from text

jrobinsonTZZT2
Observer
Observer

I have a 2D topographical survey with levels annotated to a local grid (numbers only, for example '93.76'), I need to convert to OS levels so subtract 37.93 from each of the level text annotations. Please can someone help me do it in one action rather than manually change each annotation. Working in AutoCAD LT 2022.

Thanks in advance  

0 Likes
Accepted solutions (1)
630 Views
7 Replies
Replies (7)
Message 2 of 8

cadffm
Consultant
Consultant

Hi,

there is no function to do this, but

 

1. If you are an experienced user in script .scr, then the way would be as follows: Export Text data (command LIST and LOGFILE) Powerful text editor to get rid of the useless data (you need the value and insertion point - in some cases layer and rotation plus text height too) Use excel to subtract and set up to create new texts in AutoCAD/LT by a SCRIPT (.scr)

 

2. Or, open the file in a software what can do that.

    For example AutoCAD + a Tool like this: Click! ( this sample tool requires text on layer LEVELS)

   

 
 

 

 

Sebastian

0 Likes
Message 3 of 8

Kent1Cooper
Consultant
Consultant

If you upgrade to Acad LT 2024, it can use AutoLisp routines, and there are many of those that will do what you're after.

Kent Cooper, AIA
Message 4 of 8

jrobinsonTZZT2
Observer
Observer

Now on LT 2024, but could do with AutoLisp assistance please.

0 Likes
Message 5 of 8

cadffm
Consultant
Consultant
Accepted solution

Untested with LT, but give it a try.

 

Follow my link,

download the file and extract the *.lsp file 

In LT,

Open a copy of your file, for tests

use command APPLOAD and load this .lsp [Okay]

 

Run the DP2 command and follow instructions.

 

For example

dp2<enter>

G<global>

12 or -12 or whatever number for a test.

 

 

Sebastian

Message 6 of 8

Kent1Cooper
Consultant
Consultant

@jrobinsonTZZT2 wrote:

Now on LT 2024, but could do with AutoLisp assistance please.


I'll leave it to you to Search this Forum [that's all I would do to assist] for terms like your topic wording, "increment numbers," and the like.  Elsewhere on the web are more possible sources [cadtutor, the swamp, etc.].

Kent Cooper, AIA
0 Likes
Message 7 of 8

jrobinsonTZZT2
Observer
Observer

Amazing.

 

That works perfectly!!!! Saved me hours, thank you 🙂

0 Likes
Message 8 of 8

Sea-Haven
Mentor
Mentor

Another years old.

 

; Adds a fixed amount to a number
; By Alan H

(Alert "TO USE JUST TYPE A2L or A2LM for multiple ")


;(setvar "cmdecho" 1)
(setq olddimzin (getvar "Dimzin"))
(setvar "dimzin" 0)

(DEFUN c:A2L ( / test en1 v1 a b el en1)
;(if (not AH:getvalsm)(load "Multi Getvals"))
;(setq v2 (Atof (nth 0 (AH:getvalsm (list "Add to levels" "Enter amount" 10 9 "1")))))

(setq v2 (getreal "\Enter amount to change by +ve or -ve "))
(setq test 1)
(while (= test 1)
      (setq en1 (car (entsel "\nSelect text number:" )))
       (if (/= en1 nil)
        (progn
        (setq el1 (entget en1))
        (setq v1 (atof (cdr (assoc 1 el1))))
        (setq a (+ v1 v2))
        (setq b (rtos a 2 3))
        (setq el (subst (cons 1 b) (assoc 1 el1) el1))
        (entmod el)
;        (entupd en1)
        );progn
       (princ "\nplease pick again"); else
     );if
); while true
(setq el nil)
(setq en nil)
(setq a nil)
(setq v1 nil)

(setvar "cmdecho" 1)
(setvar "dimzin" olddimzin)
(princ)
); END a2l DEFUN

(defun c:A2LM ()
;(if (not AH:getvalsm)(load "Multi Getvals"))
;(setq v2 (Atof (nth 0 (AH:getvalsm (list "Add to levels" "Enter amount" 10 9 "1")))))

(setq v2 (getreal "\Enter amount to change by +ve or -ve "))

(setq ss (ssget (list (cons 0 "Text"))))
(setq len (sslength ss))
(setq x 0)

(repeat len
(setq en1 (ssname ss x))
        (setq el1 (entget en1))
        (setq v1 (atof (cdr (assoc 1 el1))))
        (setq a (+ v1 v2))
        (setq b (rtos a 2 3))
        (setq el (subst (cons 1 b) (assoc 1 el1) el1))
        (entmod el)
(setq x (+ x 1))
); repeat

(setq el nil
      ss nil)
(setq en nil)
(setq a nil)
(setq v1 nil)

(setvar "dimzin" olddimzin)
(setvar "cmdecho" 1)
(princ)

); END a2lm DEFUN
0 Likes