Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looking for LISP routine file that can add or subtract text numbers 1

Status
Not open for further replies.

xantics

Civil/Environmental
Mar 13, 2003
11
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
 
Replies continue below

Recommended for you

Here's one I wrote, may do the job;

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]
 
Hope this works better if I get the formatting codes correct:

Code:
(defun c:txm()
   (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)
 
Thank you Carl!!! Your lisp routine did the trick and saved me many hours of manually inputting the changes to every spot elevation. Thanks again!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor