Jump to content

How about lisp to find same texts in drawing


ngolynguyen

Recommended Posts

Sorry but i found many many topic in there but not work for me until now.

All I looking for is a lisp that can find same mtext (ex: i have mtext 28-00988_44332, it appear so many time in drawing) and then highlight / change color / or something to make it different than other.

Pls help me

Link to comment
Share on other sites

Do you need a lisp?

 

I would be tempeted to use QSELECT and select text by contents and then make the chagnes in the properties panel.

 

CADnoob qselect text based on content.png

CADnoobqselecttext.png

Edited by TheCADnoob
Link to comment
Share on other sites

And you tested that suggestion?

 

yes seemed to work with my simple test run. It may give problems if text string is not necesarily unique or is similar to other strings.

 

That said i originally attached the wrong photo. I fixed that.

Link to comment
Share on other sites

Do you need a lisp?

 

I would be tempeted to use QSELECT and select text by contents and then make the chagnes in the properties panel.

 

[ATTACH]62478[/ATTACH]

 

Do we have a lisp if Im using Cad 2007?

Link to comment
Share on other sites

Try the SST lisp from here. Works for MTexts too.

Select the source text then select similar texts. The lisp search for EXACT match of source text.

Or you can skip the source object then specify the pattern to search.

The pattern accept wildcards:

- *ABC* select all text containing the sequence ABC

- ABC* select all text starting with ABC

- *ABC select all text ending with ABC

More about wildcard.

Note: Keep in mind that a Mtext can be formatted, so for example the pattern ABC* might not select the objects that apparently start with ABC (the true content of the mtext might be {\fArial|b0|i0|c0|p34;ABCDEF}

Link to comment
Share on other sites

I had fun too:

 



(defun C:test ( / tgassoc *error* dcl des dch dcf v c vx SS )
 
 ; Toggle associator - connect toggle value (0 or 1) with symbol value (nil or T):
 ; (setq tgval (tgassoc (get_tile "tg")))
 ; (set_tile "tg" (tgassoc tgval))
 (defun tgassoc ( keyorval ) (cadr (assoc keyorval '((nil "0")(T "1")("0" nil)("1" T)))) )
 
 (vl-every 'eval 
   '(
     (cond ( (not vlax-get-acad-object) (vl-load-com) (princ) vlax-get-acad-object) (vlax-get-acad-object) ( (alert "\nVisual lisp extensions not loaded.") ) )
     (setq *error*
       (lambda ( msg )
         (and (< 0 dch) (unload_dialog dch))
         (and (eq 'FILE (type des)) (close des))
         (and (eq 'STR (type dcl)) (findfile dcl) (vl-file-delete dcl))
         (and msg (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\nError: " msg)))) (princ)
       ); lambda 
     ); setq *error*
     (setq dcl (vl-filename-mktemp nil nil ".dcl"))
     (setq des (open dcl "w"))
     (foreach x
       '((116 101 115 116 32 58 32 100 105 97 108 111 103) 
         (123 32 108 97 98 101 108 32 61 32 34 83 101 108 101 99 116 32 98 121 32 116 101 120 116 32 99 111 110 116 101 110 116 34 59) 
         (32 32 58 32 98 111 120 101 100 95 99 111 108 117 109 110) 
         (32 32 123 32 99 104 105 108 100 114 101 110 95 97 108 105 103 110 109 101 110 116 32 61 32 99 101 110 116 101 114 101 100 59) 
         (32 32 32 32 58 32 116 101 120 116 32 123 32 118 97 108 117 101 32 61 32 34 83 101 97 114 99 104 32 112 97 116 116 101 114 110
           58 32 34 59 32 105 115 95 100 101 102 97 117 108 116 32 61 32 116 114 117 101 59 32 125
         ) 
         (32 32 32 32 58 32 101 100 105 116 95 98 111 120 32 123 32 107 101 121 32 61 32 34 101 98 34 59 32 101 100 105 116 95 119 105
           100 116 104 32 61 32 50 54 59 32 125
         )
         (32 32 32 32 58 32 116 111 103 103 108 101 32 123 32 107 101 121 32 61 32 34 99 34 59 32 108 97 98 101 108 32 61 32 34 73 103
           110 111 114 101 32 99 97 115 101 34 59 32 97 108 105 103 110 109 101 110 116 32 61 32 99 101 110 116 101 114 101 100 59 32 118
           97 108 117 101 32 61 32 49 59 32 109 110 101 109 111 110 105 99 32 61 32 34 99 34 59 32 125 32
         )
         (32 32 32 32 115 112 97 99 101 114 59) 
         (32 32 125) 
         (32 32 58 32 98 117 116 116 111 110 32 123 32 107 101 121 32 61 32 34 115 34 59 32 108 97 98 101 108 32 61 32 34 83 101 108 101
           99 116 32 62 62 34 59 32 102 105 120 101 100 95 119 105 100 116 104 32 61 32 116 114 117 101 59 32 104 101 105 103 104 116 32
           61 32 50 59 32 97 108 105 103 110 109 101 110 116 32 61 32 99 101 110 116 101 114 101 100 59 32 125
         )
         (32 32 115 112 97 99 101 114 59 32 58 32 98 117 116 116 111 110 32 123 32 108 97 98 101 108 32 61 32 34 68 111 110 101 34 59
           32 105 115 95 99 97 110 99 101 108 32 61 32 116 114 117 101 59 32 102 105 120 101 100 95 119 105 100 116 104 32 61 32 116 114
           117 101 59 32 97 108 105 103 110 109 101 110 116 32 61 32 99 101 110 116 101 114 101 100 59 32 125 32 58 32 116 101 120 116 32 
           123 32 107 101 121 32 61 32 34 101 114 114 111 114 34 59 32 118 97 108 117 101 32 61 32 34 67 114 101 100 105 116 115 32 116 
           111 58 32 76 101 101 32 77 97 99 34 59 125
         ) 
         (125)
       )
       (princ (apply 'strcat (mapcar 'chr x)) des)
     ); foreach
     (not (setq des (close des)))
     (< 0 (setq dch (load_dialog dcl)))
     (new_dialog "test" dch)
     (mapcar '(lambda (a b) (action_tile a (apply 'strcat (mapcar 'chr b))))
       '("c" "eb" "s")
       '(
         (40 105 102 32 40 115 101 116 113 32 99 32 40 116 103 97 115 115 111 99 32 36
           118 97 108 117 101 41 41 32 40 115 101 116 95 116 105 108 101 32 34 101 98 34
           32 40 115 101 116 113 32 118 32 40 115 116 114 99 97 115 101 32 40 103 101 116
           95 116 105 108 101 32 34 101 98 34 41 41 41 41 41
         )
         (40 115 101 116 95 116 105 108 101 32 34 101 114 114 111
           114 34 32 34 34 41 32 40 115 101 116 113 32 118 32 36 118 97 108 117 101 41
         )
         (40 67 79 78 68 32 40 40 79 82 32 40 78 79 84 32 86 41 32 40 61
           32 86 32 34 34 41 41 32 40 83 69 84 95 84 73 76 69 32 34 101 114
           114 111 114 34 32 34 83 112 101 99 105 102 121 32 115 101 97 114
           99 104 32 112 97 116 116 101 114 110 33 34 41 32 40 77 79 68 69
           95 84 73 76 69 32 34 101 98 34 32 50 41 41 32 40 84 32 40 73 70
           32 67 32 40 83 69 84 81 32 86 32 40 83 84 82 67 65 83 69 32 86 41
           41 41 32 40 68 79 78 69 95 68 73 65 76 79 71 32 49 41 41 41
         )
       )
     )
     (= 1 (setq dcf (start_dialog)))
     (progn
       (setq SS (ssadd))
       (vlax-for o (vla-get-Block (vla-get-ActiveLayout (vla-get-ActiveDocument (vlax-get-acad-object))))
         (and 
           (vlax-property-available-p o 'TextString)
           (setq vx (vla-get-TextString o))
           (wcmatch (cond (c (strcase vx)) (vx)) v)
           (ssadd (vlax-vla-object->ename o) SS)
         )
       )
       (sssetfirst nil SS)
     )
   )
 ); and 
 
 (*error* nil) (princ)
); defun C:test 
(vl-load-com) (princ)

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