Jump to content

Select specified texts in ddedit dialog.


wimal

Recommended Posts

I have written several places of my drawing following texts

MDB/L7/Z1/M1/2L3

MDB/L7/Z1/M1/2L2

EMDB/L7/Z1/M1/2L3

EMDB/L7/Z1/M1/2L2

ect.

 

I need change this L7 to L4 in next drawing.

Is there a facility or lisp code to select this L7 at once inside the DDEDIT dialog box.

Then I can type L4 replacing L7.

Link to comment
Share on other sites

I have written several places of my drawing following texts

MDB/L7/Z1/M1/2L3

MDB/L7/Z1/M1/2L2

EMDB/L7/Z1/M1/2L3

EMDB/L7/Z1/M1/2L2

ect.

 

I need change this L7 to L4 in next drawing.

Is there a facility or lisp code to select this L7 at once inside the DDEDIT dialog box.

Then I can type L4 replacing L7.

 

 

both my vt.lsp and ct.lsp can do this and also Lee Mac has a ton of utilities to do the job. Just search this forum.

 

 

gr. Rlx

Link to comment
Share on other sites

This should change the first L7 that in the selected text.

 

(defun c:Test (/ ss sn p st e )
 ;; Tharwat 29.9.2015 ;;
 (if (setq ss (ssget "_:L" '((0 . "TEXT")(1 . "*L7*"))))
 (while (setq sn (ssname ss 0))
   (if (setq p (vl-string-search "L7" (setq st (cdr (assoc 1 (setq e (entget sn)))))))  
   (entmod (subst (cons 1 (strcat (substr st 1 p) "L4" (substr st (+ 3 p)))) (assoc 1 e) e))
     )
   (ssdel sn ss)
   )
 )
(princ)
)

Link to comment
Share on other sites

This should change the first L7 that in the selected text.

 

(defun c:Test (/ ss sn p st e )
 ;; Tharwat 29.9.2015 ;;
 (if (setq ss (ssget "_:L" '((0 . "TEXT")(1 . "*L7*"))))
 (while (setq sn (ssname ss 0))
   (if (setq p (vl-string-search "L7" (setq st (cdr (assoc 1 (setq e (entget sn)))))))  
   (entmod (subst (cons 1 (strcat (substr st 1 p) "L4" (substr st (+ 3 p)))) (assoc 1 e) e))
     )
   (ssdel sn ss)
   )
 )
(princ)
)

Thanks... above code fulfilled my requirements more than I expected.

Link to comment
Share on other sites

This should change the first L7 that in the selected text.

 

Good stuff Tharwat - though as a minor suggestion, since you are restricting the original selection, you can be guaranteed that the pattern will be present and therefore a simple vl-string-subst will suffice, e.g.:

(defun c:test ( / e i s x )
   (if (setq s (ssget "_:L" '((0 . "TEXT") (1 . "*L7*"))))
       (repeat (setq i (sslength s))
           (setq e (entget (ssname s (setq i (1- i))))
                 x (assoc 1 e)
           )
           (entmod (subst (cons 1 (vl-string-subst "L4" "L7" (cdr x))) x e))
       )
   )
   (princ)
)

Lee Mac has a ton of utilities to do the job.

 

So I recommended you this lisp by the legend Lee Mac.

http://lee-mac.com/bfind.html

 

Many thanks for the recommendations guys! :)

Link to comment
Share on other sites

Mr. Tharwat Why cant I used it this way

 

(defun c:Test (/ ss sn p st e  find replase)
 ;; Tharwat 29.9.2015 ;;

 (setq find (getstring "Find "))
 (setq replace (getstring "Replase "))
 

 
 (if (setq ss (ssget "_:L" '((0 . "TEXT")(1 . *find*))))
 (while (setq sn (ssname ss 0))
   (if (setq p (vl-string-search exist (setq st (cdr (assoc 1 (setq e (entget sn)))))))  
   (entmod (subst (cons 1 (strcat (substr st 1 p) replace (substr st (+ 3 p)))) (assoc 1 e) e))
     )
   (ssdel sn ss)
   )
 )
(princ)
)

Link to comment
Share on other sites

Mr. Tharwat Why cant I used it this way

 

(defun c:Test (/ ss sn p st e  find replase)
 ;; Tharwat 29.9.2015 ;;

 (setq find (getstring "Find "))
 (setq replace (getstring "Replase "))
 
 (if (setq ss (ssget "_:L" '((0 . "TEXT")(1 . *find*))))
 (while (setq sn (ssname ss 0))
   (if (setq p (vl-string-search exist (setq st (cdr (assoc 1 (setq e (entget sn)))))))  
   (entmod (subst (cons 1 (strcat (substr st 1 p) replace (substr st (+ 3 p)))) (assoc 1 e) e))
     )
   (ssdel sn ss)
   )
 )
(princ)
)

 

See the changes:

 

(defun c:test (/ ss sn st e find replace)
 ;; Tharwat 29.9.2015 ;;
 (if (and (/= "" (setq find (getstring "\nFind :")))
          (/= "" (setq replace (getstring "\nReplace :")))
          (setq
            ss (ssget "_:L"
                      (list '(0 . "TEXT") (cons 1 (strcat "*" find "*")))
               )
          )
     )
   (while (setq sn (ssname ss 0))
     (setq e  (entget sn)
           st (cdr (assoc 1 e))
     )
     (entmod (subst (cons 1 (vl-string-subst replace find st))
                    (assoc 1 e)
                    e
             )
     )
     (ssdel sn ss)
   )
 )
 (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...