FIND command that will recognize multiple lines of text at once

FIND command that will recognize multiple lines of text at once

anderson51
Advocate Advocate
3,683 Views
40 Replies
Message 1 of 41

FIND command that will recognize multiple lines of text at once

anderson51
Advocate
Advocate

Is there a find/replace lisp routine will allow you to FIND multiple lines of "hard returned" text within a leader...and REPLACE multiple lines of "hard returned" texts?

 

 

Thanks,

 

Anderson51

 

0 Likes
3,684 Views
40 Replies
Replies (40)
Message 41 of 41

john.uhden
Mentor
Mentor

Make that 5 1/2 jugs.

This will (hopefully) find a given string in a selection set of mtext and multileader objects and select them (with blue grips).  But I doubt that I will try to do a replacement.

Anyway...

There is no undo or error control (but I'm not changing anything in the drawing).

It will likely stumble if formatting codes have been added within the text to find.

It does ignore "\n" and "\\P."

The 'found' variable (selection set) is left global in case you want to highlight or select them again, as in either:

Command: Select; !found

or

(sssetfirst nil found)

(defun c:FindHard ( / *error* mss find i e obj str)
  (defun @Anonymous-subst (new old str)
    (while (vl-string-search old str)
      (setq str (vl-string-subst new old str))
    )
    str
  )
  (and
    (setq mss (ssget '((0 . "MTEXT,MULTILEADER"))))
    (setq find (getstring 1 "\nEnter string to find (case doesn't matter): "))
    (setq find (strcase find))
    (setq found (ssadd))
    (repeat (setq i (sslength mss))
      (setq e (ssname mss (setq i (1- i))))
      (setq obj (vlax-ename->vla-object e))
      (setq str (vlax-get obj 'TextString))
      (foreach char '("\n" "\\P")
        (setq str (@string-subst " " char str))
      )
      (setq str (strcase str))
      (if (vl-string-search find str)
        (ssadd e found)
        1
      )
    )
  )
  (if found (sssetfirst nil found))
  (princ)
)
(defun c:FH ()(c:FindHard))

John F. Uhden

0 Likes