×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to make a Icon that changes text strings???...
2

How to make a Icon that changes text strings???...

How to make a Icon that changes text strings???...

(OP)
What I am trying to do is make a vba script, lisp, or macro that will let me select a toolbar button then click a piece of text and it will add the text of the button...

Example: (Wire Diagram)  ------ BLACK --------

1. Click the "GREEN" icon button...
2. Click the "BLACK" text string...
3. It will change to "GREEN"...

Ending up like this:  ------- GREEN -------

Any ideas how to accomplish this????

RE: How to make a Icon that changes text strings???...

(OP)
This is kinda the path that I am currently on...

(Defun c:wirecolorgreen ()
(setq wirecolor (entsel "\n Select Text to make GREEN:"))
(setq wirecolorvalue "GREEN")
(command "ddedit" wirecolorvalue wirecolor "")
(princ)
)

But I can't get it to work...Please HELP...

RE: How to make a Icon that changes text strings???...

I don't think you'll be able to work with "ddedit".  Here's a version thant uses 'entmod' to change the text.

(Defun c:green ()
(setq textent (car (entsel "\n Select Text to make GREEN:")))
(setq edata (entget  textent))
(setq wirecolorvalue "GREEN")
(setq Newdata (subst (cons 1 wirecolorvalue) (assoc 1 edata) edata))
(entmod NewData)
(princ)
)

RE: How to make a Icon that changes text strings???...

(OP)
Thanks SOOOO much.  That worked perfect.  Thanks.
You SOOO rock...thanks

RE: How to make a Icon that changes text strings???...

willb5150,

You can also use the CHANGE command.

For example:

(defun c:wiregreen ()
(setq TEXTENT (entsel "\nSelect TEXT to make GREEN: "))
(command "CHANGE" TEXTENT "" "P" "C" GREEN "")
(princ)
)

Hope this helps,
Paul

RE: How to make a Icon that changes text strings???...

You're Soooo welcome. :)

Next you may want to enhance it to loop while you do multiple picks, or select a group of text, or ???

You might also have just 1 "change color" button, but it has an option of a few colors, then go to selecting text.  Saves on icon space.

RE: How to make a Icon that changes text strings???...

(OP)
thanks again to both of you...you guys really helped...

RE: How to make a Icon that changes text strings???...

Hey Paul...your CHANGE approach changes the COLOR of the text to green, but willb50 wants to change the actual text to read "green".  There may be a command line way to edit text but I couldn't come up with it.

RE: How to make a Icon that changes text strings???...

This LISP changes text.  
It is not mine but I forgot where I got it so I can't give proper credit.
Type CT or pick the button.
Pick all the text you want to change.
Type the old text string BLACK
Type the new text string GREEN
All text BLACK changes to GREEN

;
(DEFUN C:CT (/ p l n e os as ns st s nsl osl sl si chf chm olderr) ; Correct spelling errors
   (setq olderr  *error*             ; Initialize variables
         *error* chgterr
         chm     0)
   (setq p (ssget))                  ; Select objects
   (if p (progn                      ; If any objects selected
      (while (= 0 (setq osl (strlen (setq os (getstring t "\nOld string: ")))))
            (princ "Null input invalid")
      )
      (setq nsl (strlen (setq ns (getstring t "\nNew string: "))))
      (setq l 0 n (sslength p))
      (while (< l n)                 ; For each selected object...
         (if (= "TEXT"               ; Look for TEXT entity type (group 0)
                (cdr (assoc 0 (setq e (entget (ssname p l))))))
            (progn
               (setq chf nil si 1)
               (setq s (cdr (setq as (assoc 1 e))))
               (while (= osl (setq sl (strlen
                             (setq st (substr s si osl)))))
                  (if (= st os)
                      (progn
                        (setq s (strcat (substr s 1 (1- si)) ns
                                        (substr s (+ si osl))))
                        (setq chf t) ; Found old string
                        (setq si (+ si nsl))
                      )
                      (setq si (1+ si))
                  )
               )
               (if chf (progn        ; Substitute new string for old
                  (setq e (subst (cons 1 s) as e))
                  (entmod e)         ; Modify the TEXT entity
                  (setq chm (1+ chm))
               ))
            )
         )
         (setq l (1+ l))
      )
   ))
   (princ "Changed ")                ; Print total lines changed
   (princ chm)
   (princ " text lines.")
   (terpri)
   (setq *error* olderr)             ; Restore old *error* handler
   (princ)
)
;

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources