×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

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]

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

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)

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

(OP)
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!!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources