Jump to content

Find & Replace


dbroada

Recommended Posts

I'm sorry to be asking this as I should be able to do it myself and indeed have routines that ALMOST do what I need, but as usual I am in a hurry. :(

 

Has anybody got a routine that will replace the 2nd character in a (select by mouse) string with "Z"?

 

That is I need to select the text GS-1330/1A and have it updated to GZ-1330/1A

 

-------------------------------

 

I've now read what I need to do properly and I should be asking for the 2nd letter to become a Y

Link to comment
Share on other sites

not easily as the first letter isn't fixed. I have done one sheet (out of many) with find A?- replace with AY- but I have a complete alphabet to go through.

 

Searching for ??- gives me ?Y- :)

Link to comment
Share on other sites

(defun c:test (/ ss)
 (if (setq ss (ssget "_:L" '((0 . "MTEXT,TEXT"))))
   ((lambda (i / ent s)
      (while (setq e (ssname ss (setq i (1+ i))))
        (setq s (cdr (assoc 1 (setq ent (entget e)))))
        (entmod (subst (cons 1 (strcat (substr s 1 1) "Y" (substr s 3))) (cons 1 s) ent))
      )
    )
     -1
   )
 )
 (princ)
)

Link to comment
Share on other sites

(defun c:test (/ ss replace)
 (if (and (setq ss (ssget "_:L" '((0 . "MTEXT,TEXT"))))
          (/= "" (setq replace (getstring "\nSpecify replacement letter: ")))
     )
   ((lambda (i / ent s)
      (while (setq e (ssname ss (setq i (1+ i))))
        (setq s (cdr (assoc 1 (setq ent (entget e)))))
        (entmod (subst (cons 1 (strcat (substr s 1 1) replace (substr s 3))) (cons 1 s) ent))
      )
    )
     -1
   )
 )
 (princ)
)

Link to comment
Share on other sites

thanks Alan, I'll try it on Monday but the problem has gone away (from me). I went home early unwell yesterday and left the problem with somebody else :D Should be done by Monday!

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