Jump to content

Recommended Posts

Posted

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

 

Any ideas guys?

 

Cheers, H.

Posted

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.

Posted

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:

~*[~`.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/ENU/filesALR/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-6754.htm

Posted

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! :)

Posted

Just one thing, as MSasu's said: MText could have formatting codes inside. This might screw with wildcard searches.

Posted
Something like this might select all text which only contains numerals and decimal points:
~*[~`.0123456789]*

 

Instead of the double-negative, how about:

 

~*@*

Posted

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:

~*[@.]*

Hopefully the "." catches stuff like punctuation. But then what about a decimal point?

 

Even the double neg can be shortened quite drastically:

~*[~#`.]*

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

~*[~`-#`.`,'" +]*

Posted

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.

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