dbroada Posted June 25, 2010 Posted June 25, 2010 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 Quote
ReMark Posted June 25, 2010 Posted June 25, 2010 Wouldn't you be able to do this using the normal FIND command and wildcards? Quote
dbroada Posted June 25, 2010 Author Posted June 25, 2010 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- Quote
alanjt Posted June 25, 2010 Posted June 25, 2010 (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) ) Quote
alanjt Posted June 25, 2010 Posted June 25, 2010 (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) ) Quote
dbroada Posted June 26, 2010 Author Posted June 26, 2010 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 Should be done by Monday! Quote
Recommended Posts
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.