Jump to content

Wildcard text search


johnengineer

Recommended Posts

are you simply wanting to find just text anywhere within the drawing? if you're wanting to do no more than that, use the FIND command. if it's any info more than that, someone else would have to get an answer to ya. 8)

Link to comment
Share on other sites

the asteric as the wild card plus what ever else for example * HOLES would select every piece of text with the word HOLES at the end of it

Link to comment
Share on other sites

*thread jack*

 

Daniel, heard you guys got some serious storms last night.... how's the trees/roofs in your area? :)

 

we got some hail but really that was about it, heard that a funnel cloud try'd to form but i didnt see anything, all the sirens went off though. there wasn't even a breeze so no wind damage.

Link to comment
Share on other sites

More advanced search patterns available via lisp. For example search Text and MText with WCMATCH function patterns:

 

(defun c:wildsearch(/ wPat tSet tLst mSet)
 (vl-load-com)
 (if
   (and
     (setq wPat
    (getstring T "\nSpecify search pattern: "))
     (setq tSet(ssget "_X" '((0 . "TEXT,MTEXT"))))
     ); end and
   (progn
    (setq tLst(mapcar 'vlax-ename->vla-object
                    (vl-remove-if 'listp
                     (mapcar 'cadr(ssnamex tSet))))
   mSet(ssadd)
   ); end setq
    (foreach ent tLst
      (if
 (wcmatch(vla-get-TextString ent)wPat)
 (ssadd(vlax-vla-object->ename ent)mSet)
 ); end if
      ); end foreach
      (if mSet
 (progn
   (sssetfirst nil mSet)
   (princ
     (strcat(itoa(sslength mset)) " selected "))
   ); end progn
 (princ "\nNothing found. ")
 ); end if
      ); end progn
    ); end if
 (princ)
 ); end of c:wildsearch

 

Available pattern symbols from WCMATCH function help:

 

# (pound)

Matches any single numeric digit

 

@ (at)

Matches any single alphabetic character

 

. (period)

Matches any single nonalphanumeric character

 

* (asterisk)

Matches any character sequence, including an empty one, and it can be used anywhere in the search pattern: at the beginning, middle, or end

 

? (question mark)

Matches any single character

 

~ (tilde)

If it is the first character in the pattern, it matches anything except the pattern

 

[...]

Matches any one of the characters enclosed

 

[~...]

Matches any single character not enclosed

 

– (hyphen)

Used inside brackets to specify a range for a single character

 

, (comma)

Separates two patterns

 

` (reverse quote)

Escapes special characters (reads next character literally)

 

You can use several patterns separated by comma.

Link to comment
Share on other sites

I just cut and copied this from a post that I replied to yesterday but it seems to aply:

 

I love the filter command. It is perhaps one of my most used power moves in CAD

Here is what you do:

 

First with Mtext type "I like Cats"

Then type "I like dogs"

Then type "I hate fish"

 

Type filter at the command line. When the pop up window comes up click on the "Add Selected Object" button, and then select "I like Cats"

In the dialog box there will be a bunch of stuff listed. Delete every thing accept:

Object = text

Text Value = I like cats

Now click on The Text Value line, and click the edit item button

in the Selected filter column you will see "I like cats" appear. Replace that text with *like* and then click add to list. Now go back and delete the text value that reads I like cats. Click apply and select all of the text on your drawing. Only the lines that say I like cats, and I like dogs will be selected.

 

Apply the same principal to your actual work and there you have it

Link to comment
Share on other sites

  • 5 years later...
I just cut and copied this from a post that I replied to yesterday but it seems to aply:

 

I love the filter command. It is perhaps one of my most used power moves in CAD

Here is what you do:

 

First with Mtext type "I like Cats"

Then type "I like dogs"

Then type "I hate fish"

 

Type filter at the command line. When the pop up window comes up click on the "Add Selected Object" button, and then select "I like Cats"

In the dialog box there will be a bunch of stuff listed. Delete every thing accept:

Object = text

Text Value = I like cats

Now click on The Text Value line, and click the edit item button

in the Selected filter column you will see "I like cats" appear. Replace that text with *like* and then click add to list. Now go back and delete the text value that reads I like cats. Click apply and select all of the text on your drawing. Only the lines that say I like cats, and I like dogs will be selected.

 

Apply the same principal to your actual work and there you have it

i have benefit from your post today thank you very much ...:)

Link to comment
Share on other sites

  • 10 years later...

Hello everyone. this code is very good.

I would like to select the text regardless of whether it is uppercase or lowercase.

it is possible?

search example: Low@@@@@E / LOWER@@@E / lower@@@@ / *lower* / LOWERC* / Lower*  

etc

     

 

Best regards

image.png.b10603301f9c370a957f7fd05e53c1fa.png

Link to comment
Share on other sites

This will find any text or mtext that contains what you input regardless of capitalization and then select/highlight it.

 

image.png.7fc38cccfaf9444b5e270896b0f41e17.png

 

;;----------------------------------------------------------------------------;;
;; Find and Select Text
(defun C:FTXT (/ str SS)
  (setq str (strcat "*" (getstring "\nPattern to find: ") "*"))  
  (if (setq SS (ssget "_X" (list (cons 0 "*TEXT") (cons 1 str) (cons 410 (getvar 'ctab)))))
    (prompt (strcat (itoa (sslength ss)) " items found"))
  )
  (sssetfirst nil SS)
  (princ)
)

 

Link to comment
Share on other sites

Looks like BricsCAD searches text without case sensitivity or it might be a variable BIGAL and myself have turned on IDK.

 

This will convert everything to uppercase with strcase (for matching with wcmatch) so case sensitivity doesn't matter.

;;----------------------------------------------------------------------------;;
;; Find and Select Text
(defun C:FTXT (/ ss ss1 str)
  (setq ss1 (ssadd))
  (setq str (strcat "*" (strcase (getstring "\nPattern to find: ")) "*"))  
  (if (setq ss (ssget "_X" (list '(0 . "*TEXT") (cons 410 (getvar 'ctab)))))
    (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq obj (vlax-ename->vla-object ent))
      (if (wcmatch (strcase (vla-get-TextString obj)) str)
        (setq ss1 (ssadd ent ss1))
      )      
    )
  )
  (prompt (strcat (itoa (sslength ss1)) " items found"))
  (sssetfirst nil ss1)
  (princ)
)

 

Edited by mhupp
Code Updated
  • Like 1
Link to comment
Share on other sites

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