Jump to content
ant7

change text in a drawing to anything Twice

Recommended Posts

ant7

I saw this autolisp from Lee Mac on this forum, this lips routine allows to change existing text to anything instantly, i would like to know if any body wants to help me to make this lisp routine to select top text and change it then select bottom text and change it instantly too,  thank you very much in advance, I have #  at top of pipe reducer and a # at bottom of the reducer too, so  I need to type 330 and click on the # top text and change to 3" then click on the bottom # and changed to 300,  thank you again

 

from Mr, Lee Mac  but it work only on one text at the time.

(defun c:req ( / ent enx )
   (while
       (progn (setvar 'errno 0) (setq ent (car (entsel)))
           (cond
               (   (= 7 (getvar 'errno))
                   (princ "\nMissed, try again.")
               )
               (   (null ent) nil)
               (   (not (wcmatch (cdr (assoc 0 (setq enx (entget ent)))) "TEXT,MTEXT"))
                   (princ "\nPlease select a text or mtext object.")
               )
               (   (entmod (subst '(1 . "REQUIRED") (assoc 1 enx) enx)))
           )
       )
   )
   (princ)
)

Share this post


Link to post
Share on other sites
BIGAL

Struggling a little to understand

 

For Text dbl click and all text gets highlited type 3 enter, dbl click other text type 330 enter , manual method.

 

Mtext similar dbl click, Ctrl+a, delete, type new, click. 

 

Are you saying you have lots of 2 texts to be changed with same text ? Need a image or dwg before after. Could do a as many as required from 1 - xx text items. 3 30 330  or 1 2 3 4 etc

Edited by BIGAL

Share this post


Link to post
Share on other sites
Dadgad

Check out this gem by LeeMac, as it might do what you need to do, without even needing to open the drawings.   :huh:   :celebrate:

 

This is an absolutely epic lisp, which goes without saying, since Lee wrote it!

 

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

 

Thanks Lee!    :beer:

 

When in doubt, check LeeMac out!   :thumbsup:

Share this post


Link to post
Share on other sites
ant7
9 hours ago, BIGAL said:

Struggling a little to understand

 

For Text dbl click and all text gets highlited type 3 enter, dbl click other text type 330 enter , manual method.

 

Mtext similar dbl click, Ctrl+a, delete, type new, click. 

 

Are you saying you have lots of 2 texts to be changed with same text ? Need a image or dwg before after. Could do a as many as required from 1 - xx text items. 3 30 330  or 1 2 3 4 etc

thank you for your help, see, if you change "required" for 2" on Mr. Lee AutoLisp as you click on the any text it will change to 2" Automatic, I need a lisp the continue with the click after change the 2" but now to 300, I hope I make my self more clear.   thanks 

Share this post


Link to post
Share on other sites
Tharwat

Something like this?

(defun c:Test ( / str sel int ent get )
  ;; Tharwat - Date: 19.10.2020		;;
  ;; Replace text string to user inputs	;;
  (and (/= (setq str (getstring t "\nEnter a string <enter to end> : ")) "")
       (princ (strcat "\nSelect texts to replace with < " str " > : ."))
       (setq int -1 sel (ssget "_:L" '((0 . "*TEXT"))))
       (while (setq int (1+ int) ent (ssname sel int))
         (entmod (subst (cons 1 str) (assoc 1 (setq get (entget ent))) get))
         )
       )
  (princ)
  )

 

Share this post


Link to post
Share on other sites
ant7
1 hour ago, Tharwat said:

Something like this?


(defun c:Test ( / str sel int ent get )
  ;; Tharwat - Date: 19.10.2020		;;
  ;; Replace text string to user inputs	;;
  (and (/= (setq str (getstring t "\nEnter a string <enter to end> : ")) "")
       (princ (strcat "\nSelect texts to replace with < " str " > : ."))
       (setq int -1 sel (ssget "_:L" '((0 . "*TEXT"))))
       (while (setq int (1+ int) ent (ssname sel int))
         (entmod (subst (cons 1 str) (assoc 1 (setq get (entget ent))) get))
         )
       )
  (princ)
  )

 

Yes, sir, thank you , this one does exactly the same as the one from Mr. Lee, still it update only one text at the time, can you do it to have 2 clicks instead of one click, like first click will change existing text to 2" and the 2nd click will update the bottom text to 300?

can you change this to have 2" automatic instead of put at the command line?

(and (/= (setq str (getstring t "\nEnter a string <enter to end> : ")) ")

like twice so one says 2" one click, then the second 300 second click?

 

Share this post


Link to post
Share on other sites
Tharwat

No, the program allows you to select as many as you want then replace the selected texts' strings with the string you enter.

Share this post


Link to post
Share on other sites
ant7
7 minutes ago, Tharwat said:

No, the program allows you to select as many as you want then replace the selected texts' strings with the string you enter.

my situation is, I need to change a lot of times the symbols # at top of line and the other symbol # the bottom  to (top #=2" and bottom #=300) during the day its a lot of clicking, that is why i was wondering if there is a lisp routine with the first click change the top #=2" and bottom #=300  :)

Share this post


Link to post
Share on other sites
Tharwat

Replace the list of strings to your desire one '("one" "two") as in the following routine.

(defun c:Test (/ inc lst str brk sel get)
  ;; Tharwat - Date: 19.10.2020		;;
  (setq inc 0
        lst '("one" "two")
        str '("1st" "2nd")
  )
  (while (and (not brk)
              (princ (strcat "\nSelect "
                             (nth inc str)
                             " text to replace with < "
                             (nth inc lst)
                             " > : ."
                     )
              )
         )
    (and (setq sel (ssget "_+.:S:E:L" '((0 . "*TEXT"))))
         (entmod (subst (cons 1 (nth inc lst))
                        (assoc 1 (setq get (entget (ssname sel 0))))
                        get
                 )
         )
         (setq inc (1+ inc))
         (= inc 2)
         (setq brk t)
    )
  )
  (princ)
)

 

  • Like 1

Share this post


Link to post
Share on other sites
ant7
5 minutes ago, Tharwat said:

Replace the list of strings to your desire one '("one" "two") as in the following routine.


(defun c:Test (/ inc lst str brk sel get)
  ;; Tharwat - Date: 19.10.2020		;;
  (setq inc 0
        lst '("one" "two")
        str '("1st" "2nd")
  )
  (while (and (not brk)
              (princ (strcat "\nSelect "
                             (nth inc str)
                             " text to replace with < "
                             (nth inc lst)
                             " > : ."
                     )
              )
         )
    (and (setq sel (ssget "_+.:S:E:L" '((0 . "*TEXT"))))
         (entmod (subst (cons 1 (nth inc lst))
                        (assoc 1 (setq get (entget (ssname sel 0))))
                        get
                 )
         )
         (setq inc (1+ inc))
         (= inc 2)
         (setq brk t)
    )
  )
  (princ)
)

wow! 

wow! it work super perfect, one thousand thank you

 

Share this post


Link to post
Share on other sites
Tharwat

You're welcome. :) 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
ant7
4 minutes ago, Tharwat said:

You're welcome. :) 

One last question, is there anyway to make less lines on the lisp routine? I will need to duplicate it like 20 times, one lisp for 2"/300,name of lisp will be 230,

and 2"/400, name of lisp will be 240 and so on, then 3"/300, 3"/600, 3"/800 and so on, 

Share this post


Link to post
Share on other sites
BIGAL

There are a couple of ways to do this and only have 1 set of code, this is just one suggestion.

 

It relies on you typing the function name with the values on the command line (txt2 2 300) (txt2 2 "A") note strings must have quotes.

 

If you want to type 230 on the command line you can do that by making lots of mini defuns

(defun c:230 ()(txt2 2 300)) have to repeat for all combo's you want.

 

The 3rd option more complicated is you can type tx-y where x & y are any numbers, alpha's and a reactor method is used to provide the values to say (txt2 x y) need some time to recode some existing code which uses a error trapping method.

 

; original code by Tharwat
; two text entries added by AlanH

(defun txt2 (t1 t2 / inc lst str brk sel get)
(cond 
((= (type t1) 'INT )(setq t1 (rtos t1 2 0)))
((= (type t1) 'REAL)(setq t1 (rtos t1 2 2)))
)
(cond
((= (type t2) 'INT )(setq t2 (rtos t2 2 0)))
((= (type t2) 'REAL)(setq t2 (rtos t2 2 2)))
)
  (setq inc 0
        lst (list t1 t2)
        str '("1st" "2nd")
  )
  (while (and (not brk)
              (princ (strcat "\nSelect "
                             (nth inc str)
                             " text to replace with < "
                             (nth inc lst)
                             " > : ."
                     )
              )
         )
    (and (setq sel (ssget "_+.:S:E:L" '((0 . "*TEXT"))))
         (entmod (subst (cons 1 (nth inc lst))
                        (assoc 1 (setq get (entget (ssname sel 0))))
                        get
                 )
         )
         (setq inc (1+ inc))
         (= inc 2)
         (setq brk t)
    )
  )
  (princ)
)

 

Edited by BIGAL
  • Dislike 1

Share this post


Link to post
Share on other sites
Tharwat

@BIGAL Please remove my codes from your post although that I already asked you before not to do so.

Share this post


Link to post
Share on other sites
BIGAL

Tharwat the code posted here becomes public so any one can alter it and repost an amended version. You seem to have decided that you don't like what I post here and in other forums, so contact the Administrators and I will abide by their rules.

Edited by BIGAL

Share this post


Link to post
Share on other sites
Tharwat

I posted the code for the OP either to learn from or to use but your additions make the code looks so silly and ridiculous with your blind copy and paste codes.

Share this post


Link to post
Share on other sites
Tharwat
On 10/19/2020 at 8:38 PM, ant7 said:

One last question, is there anyway to make less lines on the lisp routine? I will need to duplicate it like 20 times, one lisp for 2"/300,name of lisp will be 230,

and 2"/400, name of lisp will be 240 and so on, then 3"/300, 3"/600, 3"/800 and so on, 

 

I think the best solution would be with 2 list boxes with a dialog so the user would pick the first string then the second list box would be disabled then the program would pick the string that the user highlighted then collect the opposite string from the second list box automatically.

What do you think?

Share this post


Link to post
Share on other sites
ant7
23 minutes ago, Tharwat said:

 

I think the best solution would be with 2 list boxes with a dialog so the user would pick the first string then the second list box would be disabled then the program would pick the string that the user highlighted then collect the opposite string from the second list box automatically.

What do you think?

Thank you very much it did work very well as you your comment, Thank you very much again :)

Share this post


Link to post
Share on other sites
Tharwat
2 minutes ago, ant7 said:

Thank you very much it did work very well as you your comment, Thank you very much again :)

Excellent, you are welcome anytime. :) 

Share this post


Link to post
Share on other sites
ant7

this is what I did, I hope I did it right, when I load it into AutoCAD it works,  I show only 3, but there are like 20 or more, but I i cant thank you enough, :)

image.thumb.png.29fc563b5bdb32646b0ea21790135d9c.png

Edited by ant7

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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