Erase all text entities that are "numbers"

Discussion in 'AutoCAD' started by kzalec, Oct 22, 2004.

  1. kzalec

    kzalec Guest

    I'm looking for an AutoLISP routine that will erase all text entities that contain "numeric strings" and another routine that will erase any text entities that contain any LOWER CASE letters.
     
    kzalec, Oct 22, 2004
    #1
  2. kzalec

    Paul Turvill Guest

    When you say 'contain "numeric strings"' do you mean any string that
    includes numeric data (e.g., "This string has 5 words" or "Room 401") or
    strings that contain numeric characters exclusively (e.g., "123" or "27")?
    Same question goes for lower case.
    ___

    contain "numeric strings" and another routine that will erase any text
    entities that contain any LOWER CASE letters.
     
    Paul Turvill, Oct 22, 2004
    #2
  3. kzalec

    T.Willey Guest

    These will do what you ask. The first one will earse only text entities that have only spaces or number related characters. The second one will erase all text entities that have ANY lower case character, so if there is one lower case character, then that text entity will be erased. Right now they are set up to search the whole drawing, but you can change it so that it will be up to the user to select the entities. They both only work on dtext because of the mtext formatting things.


    Tim

    (defun c:NumErase (/ ss tent1 tstr1 slist schk1)

    (vl-load-com)
    (command "_.undo" "_end")
    (command "_.undo" "_group")
    (if (setq ss (ssget "x" '((0 . "TEXT"))))
    (while (/= (sslength ss) 0)
    (setq tent1 (ssname ss 0))
    (setq tstr1 (cdr (assoc 1 (entget tent1))))
    (setq slist (vl-string->list tstr1))
    (foreach item slist
    (if (<= 32 item 62)
    (setq schk1 "Y")
    )
    )
    (if schk1
    (vlax-invoke-method (vlax-ename->vla-object tent1) 'Delete)
    )
    (ssdel tent1 ss)
    (setq schk1 nil)
    )
    )
    (command "_.undo" "_end")
    (princ)
    )

    (defun c:ELowCase (/ ss tent1 tstr1 slist schk1)

    (vl-load-com)
    (command "_.undo" "_end")
    (command "_.undo" "_group")
    (if (setq ss (ssget "x" '((0 . "TEXT"))))
    (while (/= (sslength ss) 0)
    (setq tent1 (ssname ss 0))
    (setq tstr1 (cdr (assoc 1 (entget tent1))))
    (setq slist (vl-string->list tstr1))
    (foreach item slist
    (if (<= 97 item 122)
    (setq schk1 "Y")
    )
    )
    (if schk1
    (vlax-invoke-method (vlax-ename->vla-object tent1) 'Delete)
    )
    (ssdel tent1 ss)
    (setq schk1 nil)
    )
    )
    (command "_.undo" "_end")
    (princ)
    )
     
    T.Willey, Oct 22, 2004
    #3
  4. kzalec

    kzalec Guest

    Thanks so much. That's exactly what I was looking for.
     
    kzalec, Oct 22, 2004
    #4
  5. kzalec

    T.Willey Guest

    Cool, it was easier to write then I expected.
    Glad it worked.

    Tim
     
    T.Willey, Oct 22, 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.