Jump to content

Editing Lots Of Text At-Once?


therock005

Recommended Posts

I am looking for a way that I can gather all text inside a drawing and can massively edit it at will.

 

I know that AutoCAD has a built-in function that allows for batch find and replacing, and that other routines similar exist, but i find it a limitation that you have to search for a specific string.

 

What i need is a function that lists all available text inside the whole drawing or maybe within a specified drawing area, and then replace each instance with the desired end-result.

 

How can i get some help on this? :)

Link to comment
Share on other sites

Edit > Find > Find Where: Selected objects

 

First you select your text objects and do the above. You can check 'Replace All'.

 

Wait, you did mention you wanted more than one string at a time to be edited.

Link to comment
Share on other sites

What an odd request. Fun to write...

 

DosLib required.

 

(defun c:EAT (/ ss sLst eLst nLst)
 ;; Edit All Text (playing around)
 ;; DosLib Required
 ;; Alan J. Thompson, 05.21.10
 (if (and (or dos_proplist
              (alert "DosLib required. Please download and install.")
              (command "_.browser" "http://www.en.na.mcneel.com/doslib.htm")
          )
          (setq ss (ssget "_X" '((0 . "ATTDEF,MTEXT,MULTILEADER,TEXT"))))
     )
   (progn
     ((lambda (i)
        (while (setq e (ssname ss (setq i (1+ i))))
          ((lambda (ent)
             (or (eq 4
                     (logand 4 (cdr (assoc 70 (entget (tblobjname "layer" (cdr (assoc 8 ent)))))))
                 )
                 ((lambda (str)
                    (setq sLst (cons (cons str str) sLst)
                          eLst (cons e eLst)
                    )
                  )
                   ((lambda (s)
                      (cond
                        ((eq (cdr (assoc 0 ent)) "MULTILEADER") (cdr (assoc 304 ent)))
                        ((vl-position (cdr (assoc 0 ent)) '("ATTDEF" "MTEXT" "TEXT"))
                         (foreach x ent
                           (and (vl-position (car x) '(1 3)) (setq s (strcat s (cdr x))))
                         )
                         s
                        )
                      )
                    )
                     ""
                   )
                 )
             )
           )
            (entget e)
          )
        )
      )
       -1
     )
     (if (and sLst eLst)
       (if (setq nLst (dos_proplist "Edit All Text" "Edit text:" sLst))
         (mapcar
           (function
             (lambda (e s)
               (or (eq "" (cdr s))
                   (eq (car s) (cdr s))
                   (vla-put-textstring (vlax-ename->vla-object e) (cdr s))
               )
             )
           )
           eLst
           nLst
         )
       )
       (alert "No text on unlocked layers!")
     )
   )
 )
 (princ)
)

eat.jpg

Link to comment
Share on other sites

But odd is good though, i hope! Thank you for being such a team player!!! This will help me a lot in the future.

 

But could it be tweaked a little bit further and allow me to specify the region i want the text to be in?

 

Cause with this method all text is displayed, and now i have this drawing with over 700 text entries and i get lost with what i want to replace!!!

 

But great effort, i wonder why no one else finds this productive!

Link to comment
Share on other sites

Selection method (this I kind of like)...

 

(defun c:EAST (/ ss sLst eLst nLst)
 ;; Edit All Selected Text
 ;; DosLib Required
 ;; Alan J. Thompson, 05.21.10
 (if (and (or dos_proplist
              (alert "DosLib required. Please download and install.")
              (command "_.browser" "http://www.en.na.mcneel.com/doslib.htm")
          )
          (setq ss (ssget "_:L" '((0 . "ATTDEF,MTEXT,MULTILEADER,TEXT"))))
     )
   ((lambda (i)
      (while (setq e (ssname ss (setq i (1+ i))))
        ((lambda (str)
           (setq sLst (cons (cons str str) sLst)
                 eLst (cons e eLst)
           )
         )
          ((lambda (s ent)
             (cond
               ((eq (cdr (assoc 0 ent)) "MULTILEADER") (cdr (assoc 304 ent)))
               ((vl-position (cdr (assoc 0 ent)) '("ATTDEF" "MTEXT" "TEXT"))
                (foreach x ent
                  (and (vl-position (car x) '(1 3)) (setq s (strcat s (cdr x))))
                )
                s
               )
             )
           )
            ""
            (entget e)
          )
        )
      )
      (if (setq nLst (dos_proplist "Edit All Text" "Edit text:" sLst))
        (mapcar
          (function
            (lambda (e s)
              (or (eq "" (cdr s))
                  (eq (car s) (cdr s))
                  (vla-put-textstring (vlax-ename->vla-object e) (cdr s))
              )
            )
          )
          eLst
          nLst
        )
      )
    )
     -1
   )
 )
 (princ)
)

eat.jpg

Link to comment
Share on other sites

Oh man thanx a lot, this really really helps.

 

I requested it cause at times i name the vertices of polygons, like A1,A2,A3,A50,A51... and i may decide at later point to add or remove vertices, so i will have to renumber the points affected.

 

Imagine having to do this manually without some kind of help!

 

That's one of the main reasons i wanted that. But at times i find myself wanting to edit lots of text inside a drawing. And selecting them one by one and going to properties to change their caption is completely tiresome when you have to deal with lots of text.

 

Once again, thank you Alan!

Link to comment
Share on other sites

Come to think of it, long ago, I saw some really old text editors that would allow up to 3 text objects to be selected for editing. I'll have to remember to put it in my LSP folder and load it when I get to work on Monday; never know, might have a use for it.

 

Enjoy and you're welcome. :)

Link to comment
Share on other sites

In my older version of Acad sitting at home, is a simple routine to revise all text via the surround box method, then only hitting the text type box. It near instantly revises all text boxed up. It will array a selection of type fonts and their attributes and you then select the text style you want to see then. Do a purge and it will get rid of all text styles not used in the drawing. Does not work on XREFs or INSERTS though.

 

A standard feature back then.

 

Wm.

Link to comment
Share on other sites

In my older version of Acad sitting at home, is a simple routine to revise all text via the surround box method, then only hitting the text type box. It near instantly revises all text boxed up. It will array a selection of type fonts and their attributes and you then select the text style you want to see then. Do a purge and it will get rid of all text styles not used in the drawing. Does not work on XREFs or INSERTS though.

 

A standard feature back then.

 

Wm.

I'm curious. Let's see it. :)

 

Here's a very very simple and crude way...

 

(defun c:Test (/ ss)
 (if (setq ss (ssget "_:L" '((0 . "MTEXT,MULTILEADER,TEXT"))))
   ((lambda (i)
      (while (setq e (ssname ss (setq i (1+ i))))
        (command "_.ddedit" e "")
      )
    )
     -1
   )
 )
 (princ)
)

Would be a lot nicer with MText with multiple lines.

Link to comment
Share on other sites

  • 8 years later...

Is it possible that you can add a text selector, so that you can limit the selection to a specific range? So i can select some texts and then invoke the lisp routine. Cause some drawing have hundreds of texts and it still get overwhelming most of the time.

Link to comment
Share on other sites

Your answer may be in the SSGET used in the code do a little home work using help etc to see what the options do. A hint you can have no automatic selection but still filter for text mtext etc.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...