Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Automatic text edition

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
BSA_drafter1
296 Views, 4 Replies

Automatic text edition

Hi,

 

I have around 2000 text to edit. Those are elevation from a survey. I need to add .380 to each of those 2000 elevations. Is there a way to put a formula somewhere to do that automaticaly?

4 REPLIES 4
Message 2 of 5
Patchy
in reply to: BSA_drafter1
Message 3 of 5
BSA_drafter1
in reply to: Patchy

I got the "formula" from your post but what am I suppose to do with it?

 

(defun c:addn ( / ss)
  (vl-load-com)
  (if (and (setq ss (ssget "X" (list (cons 0 "*text"))))
       (setq amt (getreal "\nPlease type the amount you would like to add: ")))
    (progn
      (mapcar '(lambda (z) (vla-put-textstring z (rtos (+ (atof (vla-get-textstring z)) amt) 2 3)))
          (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))
      )
    )
  (princ)
  )

Message 4 of 5
Patchy
in reply to: BSA_drafter1

Use the one from Lee Mac, one way is copy and paste to the command line, then type in :  Text_Inc    and follow the prompt.

 

 

 

 

(defun c:Text_Inc (/ *error* ParseNumbers uFlag ss)
  (vl-load-com)
  ;; Lee Mac  ~  10.03.10

  (defun *error* (msg)
    (setvar 'NOMUTT 0)
    (and uFlag (vla-EndUndoMark *doc))
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **")))
    (princ))
  

  (defun ParseNumbers (str / lst Num Aph x rtn)
    ;; Lee Mac  ~  20.09.09
    (setq lst (vl-string->list str) Num "" Aph "")
    
    (while (setq x (car lst))
      (setq lst (cdr lst))
      
      (cond (  (and (/= "" Num) (= 46 x))
               (setq Num (strcat Num (chr x))))
            
            (  (< 47 x 58)
               (setq Num (strcat Num (chr x))
                     rtn (cons Aph rtn) Aph ""))
            
            (t (setq Aph (strcat Aph (chr x))
                     rtn (cons (read Num) rtn) Num ""))))
    
    (vl-remove nil
      (vl-remove "" (reverse (cons Aph (cons (read Num) rtn))))))
  

  (setq *inc* (cond (*inc*) (1.0)))
  (setq *inc* (cond ((getreal (strcat "\nSpecify Increment <"
                                      (vl-princ-to-string *inc*) "> : ")))
                    (*inc*)))

  (setq *doc (cond (*doc) ((vla-get-ActiveDocument (vlax-get-acad-object)))))

  (setvar 'NOMUTT 1)
  (princ "\nSelect Text to Increment <All> : ")
  (if (or (ssget "_:L" '((0 . "MTEXT,TEXT")))
          (ssget "_X"  '((0 . "MTEXT,TEXT"))))
    (progn
      (setq uFlag (not (vla-StartUndoMark *doc)))
      
      (vlax-for obj (setq ss (vla-get-ActiveSelectionSet *doc))
        (vla-put-TextString obj
          (apply (function strcat)
                 (mapcar
                   (function
                     (lambda (x) (if (vl-position (type x) '(INT REAL))
                                   (vl-princ-to-string (+ x *inc*)) x)))

                   (ParseNumbers (vla-get-TextString obj))))))

      (vla-delete ss)
      (setq uFlag (vla-EndUndoMark *doc))))  

  (setvar 'NOMUTT 0)
  (princ))



Message 5 of 5
3wood
in reply to: BSA_drafter1

You can also try attached ALTEXT.vlx, settings as below:

altext04.png

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost