Author Topic: Multileader Text Color Override not found in contents  (Read 4439 times)

0 Members and 1 Guest are viewing this topic.

steve.carson

  • Newt
  • Posts: 108
Multileader Text Color Override not found in contents
« on: February 06, 2019, 11:00:54 AM »
Hi,

At work we have a program that can update various annotation based on client standards. Lately I received reports of multileaders who's text color does not change when the Mleader style is changed. I took a look at the ML's in question and found that there is no color override in the contents (i.e. {\C#...). However when you double click the text to edit it, the color override is shown in the ribbon. If I create a new MLeader, the properties look just like the old ones (no color override in the contents, but the color shows up on the ribbon), but the color will change if I change the color in the style. I can't seem to find the difference between these two ML's to be able to programatically fix the old ones to update with a MLeader style change.

Does anybody have any thoughts on how to fix these ML's?

I've attached a drawing that may explain my problem better. If you change the text color in the MLeader style, the ML's on the left stay magenta, but the one on the right will change.

Many thanks in advance.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Multileader Text Color Override not found in contents
« Reply #1 on: February 06, 2019, 11:26:43 AM »
That is a strange one .. mleaders are a fickle beast. Matchprop seemed to 'fix' them.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

steve.carson

  • Newt
  • Posts: 108
Re: Multileader Text Color Override not found in contents
« Reply #2 on: February 06, 2019, 11:41:48 AM »
Awesome, thanks Ron, I hadn't noticed that. I can work with that.

steve.carson

  • Newt
  • Posts: 108
Re: Multileader Text Color Override not found in contents
« Reply #3 on: February 06, 2019, 11:54:16 AM »
Well, upon testing it out, the matchprop does change the text color to match, but still doesn't update if I change the Mleader style.

I feel like if there was a ByStyle color option, similar to ByLayer or ByBlock, I'd be set.


Still on the hunt.



Thanks

CincyJeff

  • Newt
  • Posts: 89
Re: Multileader Text Color Override not found in contents
« Reply #4 on: February 06, 2019, 12:11:07 PM »
If I create a multileader with a color override in the text it shows in the textstring.
(vla-get-textstring obj)
"TEST {\\C1;IT} HERE"

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Multileader Text Color Override not found in contents
« Reply #5 on: February 06, 2019, 12:13:00 PM »
Well, upon testing it out, the matchprop does change the text color to match, but still doesn't update if I change the Mleader style.

I feel like if there was a ByStyle color option, similar to ByLayer or ByBlock, I'd be set.


Still on the hunt.



Thanks
Think I cracked it:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ s)
  2.   ;; RJP » 2019-02-06
  3.   (if (setq s (ssget ":L" '((0 . "multileader"))))
  4.     (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
  5.       (entmod (append (entget e) '((90 . 17056768) (92 . -1023410173))))
  6.     )
  7.   )
  8.   (princ)
  9. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

steve.carson

  • Newt
  • Posts: 108
Re: Multileader Text Color Override not found in contents
« Reply #6 on: February 06, 2019, 12:14:38 PM »
If I create a multileader with a color override in the text it shows in the textstring.
(vla-get-textstring obj)
"TEST {\\C1;IT} HERE"

That's true, and that type of color override can be removed with the StripMtext program written by Steve Doman and Joe Burke. The multileaders I'm having problems with are existing and the color override doesn't show up in the textstring.

steve.carson

  • Newt
  • Posts: 108
Re: Multileader Text Color Override not found in contents
« Reply #7 on: February 06, 2019, 12:19:27 PM »

Think I cracked it:


You Da Man!! Big thanks!

BTW, is 17056768 or -1023410173 secret code for "ByStyle"? Just curious...

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Multileader Text Color Override not found in contents
« Reply #8 on: February 06, 2019, 12:28:06 PM »
More of a sledghammer approach .. I compared the different mleaders with this code:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:comp (/ _rc a b)
  2.   (defun _rc (l)
  3.     (vl-remove-if '(lambda (x) (or (= 'ename (type (cdr x))) (vl-position (car x) '(-1 5 10)))) l)
  4.   )
  5.   (if (and (setq a (car (entsel "\nPick first object: ")))
  6.            (setq b (car (entsel "\nPick object to compare: ")))
  7.       )
  8.     (mapcar '(lambda (c d)
  9.                (if (not (equal c d))
  10.                  (print (list c d))
  11.                )
  12.              )
  13.             (_rc (entget a))
  14.             (_rc (entget b))
  15.     )
  16.   )
  17.   (princ)
  18. )
And it returned this:
Quote
Pick object to compare:
((12 101.451 27.9233 0.0) (12 189.267 27.9233 0.0))
((90 . -1023410170) (90 . -1023410173))
((110 91.5971 11.2275 0.0) (110 179.413 11.2275 0.0))
((90 . 50713604) (90 . 17056768))
((92 . -1023410170) (92 . -1023410173))
Then I went a 'entmodding' :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

steve.carson

  • Newt
  • Posts: 108
Re: Multileader Text Color Override not found in contents
« Reply #9 on: February 06, 2019, 12:32:52 PM »
Clever! Thanks for the info.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Multileader Text Color Override not found in contents
« Reply #10 on: February 06, 2019, 12:39:04 PM »

steve.carson

  • Newt
  • Posts: 108
Re: Multileader Text Color Override not found in contents
« Reply #11 on: February 06, 2019, 01:02:19 PM »
Thanks Lee!

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Multileader Text Color Override not found in contents
« Reply #12 on: February 06, 2019, 01:21:04 PM »
You're welcome - here's another way to write the two functions to better demonstrate what's going on:

Code - Auto/Visual Lisp: [Select]
  1. ;; Colour -> MLeader Colour  -  Lee Mac
  2. ;; c - [int/lst] ACI colour or list of (r g b)
  3. ;; Returns: [int] MLeader Colour value
  4.  
  5. (defun colour->mleadercolour ( c / r )
  6.     (setq r (logior (lsh 1 30) (lsh 1 31)))
  7.     (cond
  8.         (   (= 'list (type c))
  9.             (logior (apply 'logior (mapcar 'lsh c '(16 8 0))) (lsh 1 25) r)
  10.         )
  11.         (   (<= 0 c 255) (logior c (lsh 1 24) (lsh 1 25) r))
  12.         (   (= 256 c) r)
  13.     )
  14. )
  15.  
  16. ;; MLeader Colour -> Colour  -  Lee Mac
  17. ;; c - [int] MLeader Colour value
  18. ;; Returns: [int/lst] ACI colour of list of (r g b)
  19.  
  20. (defun mleadercolour->colour ( c )
  21.     (cond
  22.         (   (< 0 (logand (lsh 1 24) c)) (logand 255 c))
  23.         (   (< 0 (logand (lsh 1 25) c)) (mapcar '(lambda ( x ) (lsh (lsh c x) -24)) '(8 16 24)))
  24.         (   (= 0 (logand (~ (logior (lsh 1 30) (lsh 1 31))) c)) 256)
  25.     )
  26. )
« Last Edit: February 06, 2019, 05:32:11 PM by Lee Mac »

ahsattarian

  • Newt
  • Posts: 112
Re: Multileader Text Color Override not found in contents
« Reply #13 on: December 14, 2020, 06:44:12 AM »
This Helps U   :



Code - Auto/Visual Lisp: [Select]
  1. (defun c:mleco ()
  2.   (setq ss (ssget '((0 . "multileader"))))
  3.   (setq col (acad_colordlg (cdr (assoc 62 (tblsearch "Layer" (getvar "clayer")))) nil))
  4.   (setq n (sslength ss))
  5.   (setq k -1)
  6.   (repeat n
  7.     (setq k (1+ k))
  8.     (setq s (ssname ss k))
  9.     (setq en (entget s))
  10.     (setq obj (vlax-ename->vla-object s))
  11.     (setq txt (vla-get-textstring obj))
  12.     (setq txt (vl-string-trim "{}" txt))
  13.     (foreach e '("\\C" "\\c")
  14.       (while (and (setq x (vl-string-search e txt)) (setq y (vl-string-search ";" txt x)))
  15.         (setq txt (strcat (substr txt 1 x) (substr txt (+ 2 y))))
  16.       )
  17.     )
  18.     (vla-put-textstring obj (strcat "{\\C" (itoa col) ";" txt "}"))
  19.     (setpropertyvalue s "textcolor" col)
  20.   )
  21.   (princ)
  22. )