+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Full Member
    Discipline
    Civil
    Using
    AutoCAD 2012
    Join Date
    Apr 2009
    Location
    Sydney, Australia
    Posts
    28

    Default Delete ONLY numbers in Text/Mtext

    Registered forum members do not see this ad.

    I need to delete lots of text, but only Text/Mtext strings which contain ONLY numerical values.

    Any ideas guys?

    Cheers, H.

  2. #2
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    2,986

    Default

    For text entities is easy to solve, just create a selection set with all items and check what return the evaluation of value stored on DXF code 1 by DISTOF function - if is nil, then the label is not a number. Should account for units format - metric or imperial.
    When come to mtext entities, then should strip out first the formatting tags, which make the processing code a more complex.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  3. #3
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,630

    Default

    Look into using the filter command, and then the wildcard match of text contents, you don't even need lisp. Something like this might select all text which only contains numerals and decimal points:
    Code:
    ~*[~`.0123456789]*
    Explanation of wildcard:
    • ~ : Negate the match, i.e. select everything which does not match this
    • * : Any character or list of characters
    • [...] : A single character matching one of these contained in the brackets
    • ~ : Anything not inside the brackets
    • `. : Escape the special . (otherwise this means anything which is not alphanumeric)
    • 0123456789: Numeral digits
    So this tests if there is any character inside the string other than numerals or the decimal point. If so, it will not be selected (due to the first ~). You might want to add some other stuff too, perhaps space, + or -, etc.


    To see a full description of special characters in wildcards, check the help on wcmatch: http://docs.autodesk.com/ACD/2011/EN...b7ccc-6754.htm
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  4. #4
    Full Member
    Discipline
    Civil
    Using
    AutoCAD 2012
    Join Date
    Apr 2009
    Location
    Sydney, Australia
    Posts
    28

    Default

    Thanks for your quick replies.

    FILTER it is, I actually tried QSELECT>Mtext>>Content>Wildcard. However, my wildcard knowledge was limited. Not anymore!

    I will still have a go at the lisp at some point, may be useful if I need to process lots of drawings, in this instance however, it's only a couple of drawings.

    Cheers guys!

  5. #5
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,630

    Default

    Just one thing, as MSasu's said: MText could have formatting codes inside. This might screw with wildcard searches.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,707

    Default

    Quote Originally Posted by irneb View Post
    Something like this might select all text which only contains numerals and decimal points:
    Code:
    ~*[~`.0123456789]*
    Instead of the double-negative, how about:

    Code:
    ~*@*
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  7. #7
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,630

    Default

    Would probably work as well. Though I was attempting to catch everything other than numerical data. I.e. including any other symbols. I'd say this might be the idea rather:
    Code:
    ~*[@.]*
    Hopefully the "." catches stuff like punctuation. But then what about a decimal point?

    Even the double neg can be shortened quite drastically:
    Code:
    ~*[~#`.]*
    IMO in this case it's easier to figure out the characters you do want in the string, instead of those you don't. Thus the double negative makes it easier to add some extra punctuation (say space / comma for thousands separation, or even ' and " for feet and inches). If you don't go with the double-negative, you'd have to omit the . and add all other possibilities (just a bit much I think). So it's much easier doing something like this
    Code:
    ~*[~`-#`.`,'" +]*
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  8. #8
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,707

    Default

    Fair point Irne, I hadn't considered punctuation symbols.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  9. #9
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,630

    Default

    Registered forum members do not see this ad.

    It is of course a border-line case, depending on the OP's needs - if there is punctuation, chances are there's also alphabetic characters. I just took the request literally.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

Similar Threads

  1. Find and delete odd numbers
    By SWfangirl in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 29th Apr 2011, 06:00 pm
  2. Sum Numbers in Mtext Fields to Mtext Field
    By muurr in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 5th Mar 2011, 08:31 pm
  3. Sum of numbers in text strings
    By mikman in forum AutoLISP, Visual LISP & DCL
    Replies: 39
    Last Post: 9th Dec 2010, 08:41 pm
  4. total text numbers
    By cadman2009 in forum AutoLISP, Visual LISP & DCL
    Replies: 9
    Last Post: 20th Sep 2010, 08:47 pm
  5. Summing up m/text numbers
    By Butch in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 6th Nov 2009, 01:30 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts