Author Topic: For the life of me.  (Read 987 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
For the life of me.
« on: November 16, 2020, 05:57:11 PM »
This routine does mostly what I want. I need to select all Mtext with color overridden to red "without user input".
 
For whatever reason, this baffles!!!

Code - Auto/Visual Lisp: [Select]
  1. (defun c:MTColor (/ e o txt)
  2.   (if (and (setq e (car (entsel "\nPick mtext: ")))
  3.            (= "MTEXT" (cdr (assoc 0 (entget e))))
  4.            (setq o (vlax-ename->vla-object e))
  5.       )
  6.     (progn (setq txt (vla-get-textstring o))
  7.            (while (vl-string-search "\\C1;" txt) (setq txt (vl-string-subst "\\C256;" "\\C1;" txt)))
  8.            (vla-put-textstring o txt)
  9.     )
  10.   )
  11.   (princ)
  12. )
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

jlogan02

  • Bull Frog
  • Posts: 327
Re: For the life of me.
« Reply #1 on: November 16, 2020, 06:05:04 PM »
Never mind...

this seems to work.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:nameit (/ int o txt)
  2.   (if (setq sel (ssget "_X" '((0 . "MTEXT"))));;Mtext
  3.    (repeat (setq int (sslength sel))
  4.      (setq obj (vlax-ename->vla-object (ssname sel (setq int (1- int)))))
  5.     (progn (setq txt (vla-get-textstring obj))
  6.            (while (vl-string-search "\\C1;" txt) (setq txt (vl-string-subst "\\C256;" "\\C1;" txt)))
  7.            (vla-put-textstring obj txt)
  8.       )
  9.     )
  10.   )
  11.   (princ)
  12. )
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10