Text Replace XXX with X

Discussion in 'AutoCAD' started by johnhatfield, Sep 24, 2004.

  1. johnhatfield

    johnhatfield Guest

    Anyone have a routine to search a drawing and replace plain ol text XXX with X?

    Thanks.

    John Hatfield
     
    johnhatfield, Sep 24, 2004
    #1
  2. johnhatfield

    C Witt Guest

    command: find
     
    C Witt, Sep 24, 2004
    #2
  3. johnhatfield

    T.Willey Guest

    You can use the built in function find.

    Tim
     
    T.Willey, Sep 24, 2004
    #3
  4. johnhatfield

    Walt Engle Guest

    Try this - been using this for over 13 years:

    ; CHGTXT.LSP
    ; CHANGES TEXT STRING
    (defun c:chgtxt (/ p l n e os as ns st s nsl osl sl si chf chm cont)
    (setq chm 0 p (ssget)) ; Select objects
    (if p (progn ; If any objects selected
    (setq cont t)
    (while cont
    (setq osl (strlen (setq os (getstring "\nOld string: " t))))
    (if (= osl 0)
    (princ "Null input invalid")
    (setq cont nil)
    )
    )
    (setq nsl (strlen (setq ns (getstring "\nNew string: " t))))
    (setq l 0 n (sslength p))
    (while (< l n) ; For each selected object...
    (if (= "TEXT" ; Look for TEXT entity type (group 0)
    (cdr (assoc 0 (setq e (entget (ssname p l))))))
    (progn
    (setq chf nil si 1)
    (setq s (cdr (setq as (assoc 1 e))))
    (while (= osl (setq sl (strlen
    (setq st (substr s si osl)))))
    (if (= st os)
    (progn
    (setq s (strcat (substr s 1 (1- si)) ns
    (substr s (+ si osl))))
    (setq chf t) ; Found old string
    (setq si (+ si nsl))
    )
    (setq si (1+ si))
    )
    )
    (if chf (progn ; Substitute new
    string for old
    (setq e (subst (cons 1 s) as e))
    (entmod e) ; Modify the
    TEXT entity
    (setq chm (1+ chm))
    ))
    )
    )
    (setq l (1+ l))
    )
    ))
    (princ "Changed ") ; Print total
    lines changed
    (princ chm)
    (princ " text lines.")
    )
     
    Walt Engle, Sep 25, 2004
    #4
  5. Vladimir Michl, Sep 27, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.