Jump to content

Recommended Posts

Posted

hi good day to all. its me once again...

is this possible? changing the letter of an MText?

 

Example..

7-04DS23AG2, 7-04DS24AG2, 7-04DS25AG2, 7-04DS03AG2, 7-04DS04AG2, 7-04DS05AG2...... and so on.

 

i want to change the letter in the mtext (the bold red letter in the example) in one selection. i hope it can be done.. :) thanks in advance..

Posted

For sure it can be done – you will have to get entity’s associated list with ENTGET, change the string (is stored under DXF code 1) using SUBST and call ENTMOD to update the entity.

The challenging part will be to design the function that will modify the string – this algorithm depends of the replacement type (by position, by value).

 

Just post your first attempt and will receive assistance.

 

Regards,

Mircea

Posted

If all you want to do is change that one letter, and assuming these text entities are all in one drawing, go to the "edit" menu, down to "find". This bring up a dialog box with several options available for either just finding the text, or replacing it. Since all of those numbers end with "AG2" you can use that as your search string, and it replace that with "AX2" or whatever the "g" should change out to be. By clicking on the "options" button in that dialog, you can have it search (or not) various types of text such as block attribute values, table text, etc. simply by checking or unchecking the item.

find and replace.jpg

Posted

Here it goes Buddy. :)

 

If your char (G) is not in capital Letter , it would not replace the Text .

 

(defun c:Test (/ Nstr ss)
; Tharwat 25. 01. 2011
; Tested withAutoCAD 2010
(if (and (setq Nstr
 (getstring "\n Enterg the replacement Text :"))
 (setq ss
 (ssget '((0 . "TEXT,MTEXT"))))
 )
 (
  (lambda (i / ss1 e str GLoc 1st 2nd all)
      (while
          (setq ss1
   (ssname ss (setq i (1+ i))))
              (setq e (entget ss1))
                   (setq str
     (cdr (assoc 1 e)))
             (if
 (eq
   nil (setq GLoc
        (vl-string-search "G" str)))
             (entupd
        (cdr (assoc -1
      (entmod (subst (cons 1 str)
       (assoc 1 e)
       e)
       )
      )
      )
        )
 (progn
         (setq 1st
  (substr str 1 GLoc))       
          (setq 2nd
   (substr str (+ 2 GLoc)))
           (setq all
    (strcat 1st Nstr 2nd))
            (entupd
       (cdr (assoc -1
     (entmod (subst (cons 1 all)
      (assoc 1 e) e)
      )
     )
     )
       )
  )
 )
                 )
    )
   -1
   )
 (princ "\n No texts selected")
 )
 (princ)
 )

 

Tharwat

Posted

@msasu

thanks for the reply. but im a noob in lisp programming. still learning. thanks anyway for the inputs.. :)

 

@Jack

I never thought of that. thanks! :)

 

@ Tharwat

Works like a charm! thank you very much. :)

 

more power to you guys and God bless!

Posted

 

@ Tharwat

Works like a charm! thank you very much. :)

 

more power to you guys and God bless!

 

You're welcome Buddy. :)

 

Tharwat

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