Jump to content

Double text edit


striker0911

Recommended Posts

Hi all,

 

I was wondering if there is a way that AutoCad can edit one text string and the same change can affect another text string, instead of editing the same thing twice.

 

any help would gladly be appreciated thank you all and have a good day!! 8)

Link to comment
Share on other sites

If find and replace wont work because original text strings are not the same. select all the text strings you wish to edit, then in the properties window under contents, you can type what you want all the strings to display

Link to comment
Share on other sites

you can try to find a program out there that links objects text together. There maybe something on AUGI, I cant remember if I ever posted the source code or not.....

.... What the heck, maybe one of the experts around here will streamline it or improve it.

(defun c:textlink
             (/       text1       text2       text1obj    text1ent       text2obj
              text2ent       text1str    alltext       alltextlen  count       xdatlow
              currenttext currenttextdat       xdatno      highno       exdata
              newent1       newent2     objflag       obj2flag    text1vla       text2vla
              highno
             )
     (prompt "\nSelect Mtext or Multileader to be copied")  ;select texts objects
     (if (setq text1 (ssget ":S" '((0 . "Mtext,Multileader"))))
   (setq text1obj (ssname text1 0)
         text1vla (vlax-ename->vla-object text1obj)
         text1ent (entget text1obj)
   ) ;_ end of setq
     ) ;_ end of if
     (if (/= text1 nil)
   (progn
     (if (= (cdr (assoc 0 text1ent)) "MTEXT")
       (setq objflag 1)
       (setq objflag nil)
     ) ;_ end of if
     (while (or (= text1obj text2obj) (= text2obj nil))
       (prompt "\nSelect Mtext or Multileader to be changed")
       (if    (setq text2 (ssget ":S" '((0 . "Mtext,Multileader"))))
         (setq text2obj (ssname text2 0)
           text2vla (vlax-ename->vla-object text2obj)
           text2ent (entget text2obj)
         ) ;_ end of setq
       ) ;_ end of if
     ) ;_ end of while
     (if (= (cdr (assoc 0 text2ent)) "MTEXT")
       (setq obj2flag 1)
       (setq obj2flag nil)
     ) ;_ end of if
     (if (= objflag 1)
       (setq text1str (cdr (assoc 1 text1ent)))
       (setq text1str (vla-get-textstring text1vla))
     ) ;_ end of if
     (if (= obj2flag 1)
       (setq text2ent (subst (cons 1 text1str)
                 (assoc 1 text2ent)
                 text2ent
              ) ;_ end of subst
       ) ;_ end of setq
       (setq text2ent (subst (cons 304 text1str)
                 (assoc 304 text2ent)
                 text2ent
              ) ;_ end of subst
       ) ;_ end of setq
     ) ;_ end of if
     (entmod text2ent) ;clone first selection to second selection
     (if (setq xdatno
            (cdr
              (car
            (cdr
              (car
                (cdr
                  (assoc -3
                     (entget text1obj '("C-CAD"))
                  ) ;_ end of assoc
                ) ;_ end of cdr
              ) ;_ end of car
            ) ;_ end of cdr
              ) ;_ end of car
            ) ;_ end of cdr
         ) ;_ end of setq
       ()
       (progn
         (setq alltext    (ssget "_X" '((0 . "Mtext,Multileader")))
           alltextlen (sslength alltext)
           count      0
           xdatlow    0
         ) ;_ end of setq
         (while (< count alltextlen)
       (setq currenttext    (ssname alltext count)
             currenttextdat (entget currenttext
                        '("C-CAD")
                    ) ;_ end of entget
             highno         (cdr
                      (car
                    (cdr (car (cdr (assoc -3 currenttextdat))))
                      ) ;_ end of car
                    ) ;_ end of cdr
       ) ;_ end of setq
       (if (> highno xdatlow)
         (setq xdatlow highno)
       ) ;_ end of if
       (setq count (1+ count))
         ) ;check drawing for xdata

;find highest number

         (setq xdatno (1+ xdatlow)) ;add one
       ) ;_ end of progn
     ) ;_ end of if
     (regapp "C-CAD") ; Registers the application name.
     (setq    exdata ; Sets the variable
        (list (list -3
                (list "C-CAD" ; exdata equal to the
                  (cons 1070 xdatno)
; new extended data
                ) ;_ end of list
              ) ;_ end of list
        ) ;_ end of list
     ) ;_ end of setq
     (setq    newent1    (append text1ent exdata)
       newent2    (append text2ent exdata)
     ) ; Appends new data list to entity's list.
     (entmod newent1) ; Modifies the entity with the new definition data.
     (entmod newent2)
     (if (= (vlax-get-property text1vla 'TextLineSpacingStyle) 1)
       (progn
         (vlax-put-property text1vla 'TextLineSpacingStyle 2)
         (vlax-put-property text1vla 'TextLineSpacingFactor 1)
       ) ;_ end of progn
     ) ;_ end of if
     (if (= (vlax-get-property text2vla 'TextLineSpacingStyle) 1)
       (progn
         (vlax-put-property text2vla 'TextLineSpacingStyle 2)
         (vlax-put-property text2vla 'TextLineSpacingFactor 1)
       ) ;_ end of progn
     ) ;_ end of if
     (princ)
   ) ;_ end of progn

     ) ;_ end of if
   ) ;_ end of defun

   (defun updatetext (/        presenttext     presenttextsel      presenttextdat
              textno        presenttextstr     alltext      alltextlen
              count        currenttext     currenttextdat      currenttextvla
              presenttextvla    highno
             )
     (if (setq presenttext (ssget "_P" '((0 . "Mtext,Multileader"))))
   (progn
     (setq    presenttextsel (ssname presenttext 0)
       presenttextvla (vlax-ename->vla-object presenttextsel)
       presenttextdat (entget presenttextsel
                      '("C-CAD")
                  ) ;_ end of entget
       textno           (cdr (car (cdr (car (cdr (assoc -3 presenttextdat)))))
                  ) ;_ end of cdr
     ) ;_ end of setq
     (if (= (cdr (assoc 0 presenttextdat)) "MTEXT")
       (setq presenttextstr (cdr (assoc 1 presenttextdat)))
       (setq presenttextstr (vla-get-textstring presenttextvla))
     ) ;_ end of if
   ) ;_ end of progn
     ) ;_ end of if
;check current selection set
     (if (/= textno nil) ;if xdata exists select other text object that xdata matches
   (progn
     (setq    alltext       (ssget "_X" '((0 . "Mtext,Multileader")))
       alltextlen (sslength alltext)
       count       0
     ) ;_ end of setq
     (while (< count alltextlen)
       (setq currenttext     (ssname alltext count)
         currenttextvla (vlax-ename->vla-object currenttext)
         currenttextdat (entget currenttext
                    '("C-CAD")
                ) ;_ end of entget
         highno     (cdr
                  (car (cdr (car (cdr (assoc -3 currenttextdat)))))
                ) ;_ end of cdr
       ) ;_ end of setq
       (if    (= highno textno)
         (progn
       (if (= (cdr (assoc 0 currenttextdat)) "MTEXT")
         (setq    currenttextdat
            (subst    (cons 1 presenttextstr)
               (assoc 1 currenttextdat)
               currenttextdat
            ) ;_ end of subst
         ) ;_ end of setq
         (setq    currenttextdat
            (subst    (cons 304 presenttextstr)
               (assoc 304 currenttextdat)
               currenttextdat
            ) ;_ end of subst
         ) ;_ end of setq
       ) ;_ end of if
       (entmod currenttextdat)
       (if (= (vlax-get-property currenttextvla 'TextLineSpacingStyle) 1)
         (progn
           (vlax-put-property currenttextvla 'TextLineSpacingStyle 2)
           (vlax-put-property currenttextvla 'TextLineSpacingFactor 1)
         ) ;_ end of progn
       ) ;_ end of if
       (if (= (vlax-get-property presenttextvla 'TextLineSpacingStyle) 1)
         (progn
           (vlax-put-property presenttextvla 'TextLineSpacingStyle 2)
           (vlax-put-property presenttextvla 'TextLineSpacingFactor 1)
         ) ;_ end of progn
       ) ;_ end of if
;text clone from curren text object to second text object
         ) ;_ end of if
       ) ;_ end of if
       (setq count (1+ count))
     ) ;_ end of while
   ) ;_ end of progn
     ) ;_ end of if
     (princ)
   ) ;_ end of defun

   (defun selectx ()
     (entget (car (entsel)) '("C-CAD"))
   ) ;_ end of defun

   (defun c:textunlink    (/ ss nm count)
     (prompt "\nSelect Mtext or Multileader object(s) to be unlinked:")
     (setq ss      (ssget '((0 . "MULTILEADER,MTEXT")))
       count 0
     ) ;_ end of setq
     (while (< count (sslength ss))
   (setq nm (ssname ss count))
   (delxdata nm '("C-CAD"))
   (setq count (1+ count))
     ) ;_ end of while
   ) ;_ end of defun
   (defun DelXdata (ent app / entlst tmplst)
     (setq entlst (entget ent app))
     (foreach memb (cdr (assoc -3 entlst))
   (setq tmplst (cons -3 (list (cons (car memb) nil)))
         entlst (subst tmplst (assoc -3 entlst) entlst)
         entlst (entmod entlst)
   ) ;_ end of setq
     ) ;_ end of foreach
   ) ;_ end of defun

Link to comment
Share on other sites

Hey guys thanks for the quick responses..

 

JPlanera that is a good way to do it but im trying to make it easier for my co-workers

in the drawings that we do we use a certain text string with the same information but

in different positions within the same paper space.

I was wondering if there is a way kinda like ccowgill explains it a way to link text together

becuase my co-workers including myself sometimes forget to edit one or two of the text.

 

Thanks for your help

Link to comment
Share on other sites

Sorry, I also forgot, I have that program attached to a reactor that fires when the mtedit or mleadercontentedit are completed:

(if (not Command_Ending_Reactor)
 (setq    Command_Ending_Reactor
    (vlr-command-reactor
      nil
      '((:vlr-commandended
         .
         Command_Ended_Command
        )
       )
    ) ;_ end of vlr-command-reactor
 ) ;_ end of setq
 () ;_ the reactor is already loaded
) ;_ end of if

(defun Command_Ended_Command (In_ReactorName In_Command / LayObj tess)
(cond
((or
      (= (car In_Command) "MTEDIT")
      (= (car In_Command) "MLEADERCONTENTEDIT")
    ) ;_ end of or
    (updatetext)
   ) ;_end cond5
 ) ;_ end of cond
) ;_ end of defun

hopefully I got all the relevant parts

Link to comment
Share on other sites

Another method could utilize blocks. If you are using multiple text strings, i assume your method would be to create 1 string and then copy it to the other locations?? If this is the case, just turn the first text string into a block, then copy it. From there, editing any one of the text strings will automatically update the others. I have not tried cowgills code, it may be better for what you need, but there are options. Find and replace is a valid option as well, as tyke pointed out.

Link to comment
Share on other sites

If find and replace wont work because original text strings are not the same

but find and replace is good for this, isn't it? maybe you could use QSELECT to choose which ones to edit, but i reckon find and replace is perfect for this.

Link to comment
Share on other sites

  • 6 months later...

hey guys i found the solution to this..

 

using the fields command when you first enter a Mtext type what ever your going to need than create a second Mtext and right click on it and select opt insert field. on the dialog box select object on the far left box and in the middle top select the previous Mtext you had create when you do that select the opt content from the middle box and that should be it. now every time you update the first Mtext you created and do a Regen the second Mtext should update to display the same text as the first one.

 

Thanks to everyone for their responses

Link to comment
Share on other sites

I have a very old lisp that matches text strings. (not Mtext)

 

;;;PT.LSP by M Remfrey

;;;Rankine & Hill Limited

;;;last edit 11-7-91

(defun c:PT (/ tent otext ntext)

(graphscr)

(setvar "cmdecho" 0)

(WHILE

(setq tent (entget (car (entsel "\nSelect text to change: "))))

(setq otext (cdr (assoc 1 tent)))

(setq ntext (cdr (assoc 1 (entget (car (entsel "\nSelect new text: "))))))

(setq tent (subst (cons 1 ntext) (cons 1 otext) tent))

(entmod tent)

)

(princ)

)

 

 

Still works fine for the few times I need it. :D

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...