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????
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???...
(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???...
(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???...
You SOOO rock...thanks
RE: How to make a Icon that changes text strings???...
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???...
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???...
RE: How to make a Icon that changes text strings???...
RE: How to make a Icon that changes text strings???...
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)
)
;