Jump to content

Highlight Select Similar Text


rcb007

Recommended Posts

I found this routine which will select all similar mtexts and texts within a drawing at one time. 

I am trying to figure out how to change it from selecting all objects within the drawing, to where the user would select a text, then it would highlight select all in the drawing.

 

Any help would be great.

 

(defun c:simtxt (/ lst Hltext text i)
  (if (setq lst    nil
            HlText (ssadd)
            text   (ssget "_x"
                          (list '(0 . "MTEXT,TEXT")
                                '(-4 . "<NOT")
                                '(1 . "")
                                '(-4 . "NOT>")
                                (cons 410 (Getvar 'ctab))
                          )
                   )
      )
    (progn
      (repeat (setq i (sslength text))
        (if (setq f (Assoc (setq str
                                  (cdr
                                    (Assoc 1
                                           (entget (setq e (ssname text (setq i (1- i)))))
                                    )
                                  )
                           )
                           Lst
                    )
            )
          (progn (ssadd e HlText)
                 (if (not (ssmemb (cadr f) HlText))
                   (ssadd (cadr f) HlText)
                 )
          )
          (setq lst (cons (list str (ssname text i)) lst))
        )
      )
      (sssetfirst nil HlText)
    )
  )
  (princ))

 

thank you.

Link to comment
Share on other sites

Hi,

Be mindful is that the formatted Mtexts are not considered with this routine.

(defun c:Test (/ int sel ent str)
  ;; Tharwat - Date: 5.May.2021				;;
  ;; Select similar text contents based on selection.	;;
  (and (princ "\nSelect texts to select all similar text contents : ")
       (setq str ""
             int -1
             sel (ssget '((0 . "*TEXT")))
             )
       (while (setq int (1+ int) ent (ssname sel int))
         (setq str (strcat str (cdr (assoc 1 (entget ent))) ","))
         )
       (sssetfirst nil (ssget "_x" (list '(0 . "*TEXT") (cons 1 str) (cons 410 (getvar 'ctab)))))
       )
  (princ)
)

 

Link to comment
Share on other sites

Removing the "_X" will do the trick more here

(defun c:simtxt (/ lst Hltext text i)
  (if (setq lst    nil
            HlText (ssadd)
            text   (ssget (list '(0 . "*TEXT") ;this should do the same as '(0 . "MTEXT,TEXT")
                                '(-4 . "<NOT")
                                '(1 . "")
                                '(-4 . "NOT>")
                                (cons 410 (Getvar 'ctab))
                          )
                   )
      )
    (progn
      (repeat (setq i (sslength text))
        (if (setq f (Assoc (setq str
                                  (cdr
                                    (Assoc 1
                                           (entget (setq e (ssname text (setq i (1- i)))))
                                    )
                                  )
                           )
                           Lst
                    )
            )
          (progn (ssadd e HlText)
                 (if (not (ssmemb (cadr f) HlText))
                   (ssadd (cadr f) HlText)
                 )
          )
          (setq lst (cons (list str (ssname text i)) lst))
        )
      )
      (sssetfirst nil HlText)
    )
  )
  (princ))

 

Edited by mhupp
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...