Looking for LISP routine file that can add or subtract text numbers
Looking for LISP routine file that can add or subtract text numbers
(OP)
Hi all ACAD gurus!!! I have a topo file that was flown on a datum that was incorrect to use in the first place. There are several text strings that show elevations all around the topo file. I'd like to obtain a lisp routine that could increase all text numbers globally by 0.44'. Your assistance is most appreciated.
Thank you.
Xantics
Thank you.
Xantics





RE: Looking for LISP routine file that can add or subtract text numbers
[code]
defun c:txm()
(terpri)
;; Perform math on text numbers in-place, by Carl B, March 2000
(setvar "cmdecho" 0)
;; select lines to annotate
(setq mfactor 1 afactor 0 input nil)
(initget "M A")
(setq input (getkword "\nMultiply<M> or Add<A>?: "))
(cond
((= input "M") (initget 1)
(setq mfactor (getreal "\nMult Factor: ")))
((= input "A") (initget 1)
(setq afactor (getreal "\nAdd Amount: ")))
(T nil)
) ; cond
(initget 1)
(setq precis (getint "\nPlaces after decimal: "))
(setq units (getstring T "\nEnter units to append: "))
(princ "\nSelect text to revise: ")
(setq textset nil)
(while (not textset) (setq textset (ssget '((0 . "TEXT")))))
(setq numitems (sslength textset))
;; loop to isolate text & change text
(setq itemno 0)
(repeat numitems
(setq entname (ssname textset itemno))
;;(setq enttype (cdr (assoc 0 (entget entname))))
(setq oldtxt_pr (assoc 1 (entget entname)))
(setq oldtxt (cdr oldtxt_pr))
(setq oldtext# (atof oldtxt))
(setq newtext# (+ (* oldtext# mfactor) afactor))
(setq newtxt (strcat (rtos newtext# 2 precis) units))
(setq newtxt_pr (cons 1 newtxt))
(setq entstuff (entget entname))
(setq entstuff (subst newtxt_pr oldtxt_pr entstuff))
(entmod entstuff)
(setq itemno (1+ itemno))
) ; repeat
) ; the end
(princ "Do math on text Start with \"TXM\"")
(princ)
{/code]
RE: Looking for LISP routine file that can add or subtract text numbers
CODE
(terpri)
;; Perform math on text numbers in-place, by Carl B, coded March 2000
(setvar "cmdecho" 0)
(setq mfactor 1 afactor 0 input nil)
(initget "M A")
(setq input (getkword "\nMultiply<M> or Add<A>?: "))
(cond
((= input "M") (initget 1)
(setq mfactor (getreal "\nMult Factor: ")))
((= input "A") (initget 1)
(setq afactor (getreal "\nAdd Amount: ")))
(T nil)
) ; cond
(initget 1)
(setq precis (getint "\nPlaces after decimal: "))
(setq units (getstring T "\nEnter units to append: "))
(princ "\nSelect text to revise: ")
(setq textset nil)
(while (not textset) (setq textset (ssget '((0 . "TEXT")))))
(setq numitems (sslength textset))
;; loop to isolate text & change text
(setq itemno 0)
(repeat numitems
(setq entname (ssname textset itemno))
(setq oldtxt_pr (assoc 1 (entget entname)))
(setq oldtxt (cdr oldtxt_pr))
(setq oldtext# (atof oldtxt))
(setq newtext# (+ (* oldtext# mfactor) afactor))
(setq newtxt (strcat (rtos newtext# 2 precis) units))
(setq newtxt_pr (cons 1 newtxt))
(setq entstuff (entget entname))
(setq entstuff (subst newtxt_pr oldtxt_pr entstuff))
(entmod entstuff)
(setq itemno (1+ itemno))
) ; repeat
) ; the end
(princ "Do math on text Start with \"TXM\"")
(princ)
RE: Looking for LISP routine file that can add or subtract text numbers