Find Text LISP Routine

Find Text LISP Routine

Anonymous
Not applicable
3,059 Views
3 Replies
Message 1 of 4

Find Text LISP Routine

Anonymous
Not applicable

Hello Guys,

 

I am quite new to LISP routines. I need help with a LISP Routine that finds text and returns the count of search results in a drawing. The text could be MTEXT or within attribute. It would be great if we can also search multiple words (optional).

0 Likes
3,060 Views
3 Replies
Replies (3)
Message 2 of 4

pbejse
Mentor
Mentor

@Anonymous wrote:

Hello Guys,

 

I am quite new to LISP routines. I need help with a LISP Routine that finds text and returns the count of search results in a drawing. The text could be MTEXT or within attribute. It would be great if we can also search multiple words (optional).


 

In a way, FIND command will do that for you. Show us an example of what you are looking for.

 

 

0 Likes
Message 3 of 4

serag.hassouna
Advocate
Advocate

Well, You can try this command "textsearch",

It does the following:-

  1. It gets number of occurrences of the supplied text within the drawing.
  2. For every attribute definition it sees if its "value" and/or "tag" match the supplied text.
  3. If there's any block reference, it dives into it and searches for any match cases among its elements.

What the command prompts:

  1. Total no. of text occurrences.
  2. No. of matched attribute definition values.
  3. No of matched attribute definition tags.
0 Likes
Message 4 of 4

serag.hassouna
Advocate
Advocate

To search multiple words, you can simply append these words to a list, then use something like that

(setq words (list "w1" "w2" "w3")) ;|the list of words to be searched for,
replace [ (list "w1" "w2" "w3") ] with the appropriate appending routine. |; (setq final_results (mapcar (function (lambda (x) (textsearch_pure x nil (entnext)) );lambda );function words );mapcar );setq

But be notified that there's a downside to just repetitively lean on "textsearch_pure",i.e. if you have for example a drawing with 300 entities, this means that the above-mentioned code will work with effectively 900 entities (in length/execution time), that means, you have to think of making a routine that returns all existing "strings" within the drawing and their respective numbers of occurrences and assign it to a global variable, then simply look for the needed texts within this global variable.
But also know that this downside is really a downside only if the drawings' texts will not be modified or deleted.

 

__________________

P.S. Any arguments upon the correctness of this replay are "especially "welcomed.

0 Likes