Nikon Posted 5 hours ago Posted 5 hours ago Good day everyone! After editing the text, its color changes, but to exit the command, you need to press RMB or enter or Esc twice. Is it possible to complete the execution of the command with the right mouse button in one click? ;; If the current color is not equal to 136, then change it to 136. ;; If the current color is 136, then change it to 230. (defun c:TEcolor136_230 (/ error oldcmdecho sel e type obj res currentColor) (vl-load-com) (defun error (msg) (if oldcmdecho (setvar "CMDECHO" oldcmdecho)) (if (and msg (not (wcmatch (strcase msg) "BREAK,CANCEL,EXIT"))) (princ (strcat " Error: " msg)) ) (princ) ) (setq oldcmdecho (getvar "CMDECHO")) (setvar "CMDECHO" 0) (while (setq sel (entsel " Select TEXT/MTEXT to edit (Enter — exit): ")) (setq e (car sel) type (strcase (cdr (assoc 0 (entget e)))) ) (if (wcmatch type "TEXT,MTEXT") (progn (setq obj (vlax-ename->vla-object e)) ;; get the current color (setq currentColor (vl-catch-all-apply 'vlax-get-property (list obj 'Color)) ) ;; Error handling on receipt (if (vl-catch-all-error-p currentColor) (setq currentColor 0) ) ;; Opening the text editor (setq res (vl-catch-all-apply 'vl-cmdf (list "_.textedit" e)) ) (if (vl-catch-all-error-p res) (princ " Editing canceled.") ;; After editing, we change the color (progn (if (= currentColor 136) ;; If it's 136, change it to 230. (if (vl-catch-all-error-p (vl-catch-all-apply 'vlax-put-property (list obj 'Color 230)) ) (princ " Couldn't change color to 230.") (princ " The color has been changed to 230.") ) ) (if (/= currentColor 136) ;; If it's not 136, change it to 136. (if (vl-catch-all-error-p (vl-catch-all-apply 'vlax-put-property (list obj 'Color 136)) ) (princ " Couldn't change the color to 136.") (princ " The color has been changed to 136.") ) ) (princ " Editing completed.") ) ) ) (princ " It's not an object TEXT/MTEXT.") ) ) (setvar "CMDECHO" oldcmdecho) (princ) ) Quote
GLAVCVS Posted 5 hours ago Posted 5 hours ago (edited) Do you only need to change the color or also edit the text? Edited 5 hours ago by GLAVCVS Quote
Nikon Posted 3 hours ago Author Posted 3 hours ago 2 hours ago, GLAVCVS said: Do you only need to change the color or also edit the text? I need to edit the text and change the color. Quote
Recommended Posts
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.