TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: steve.carson on February 06, 2019, 11:00:54 AM

Title: Multileader Text Color Override not found in contents
Post by: steve.carson 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.
Title: Re: Multileader Text Color Override not found in contents
Post by: ronjonp on February 06, 2019, 11:26:43 AM
That is a strange one .. mleaders are a fickle beast. Matchprop seemed to 'fix' them.
Title: Re: Multileader Text Color Override not found in contents
Post by: steve.carson on February 06, 2019, 11:41:48 AM
Awesome, thanks Ron, I hadn't noticed that. I can work with that.
Title: Re: Multileader Text Color Override not found in contents
Post by: steve.carson 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
Title: Re: Multileader Text Color Override not found in contents
Post by: CincyJeff 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"
Title: Re: Multileader Text Color Override not found in contents
Post by: ronjonp 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. )
Title: Re: Multileader Text Color Override not found in contents
Post by: steve.carson 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.
Title: Re: Multileader Text Color Override not found in contents
Post by: steve.carson 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...
Title: Re: Multileader Text Color Override not found in contents
Post by: ronjonp 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' :)
Title: Re: Multileader Text Color Override not found in contents
Post by: steve.carson on February 06, 2019, 12:32:52 PM
Clever! Thanks for the info.
Title: Re: Multileader Text Color Override not found in contents
Post by: Lee Mac on February 06, 2019, 12:39:04 PM

Think I cracked it:


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

This old post may help -

http://www.theswamp.org/index.php?topic=37313.msg454906#msg454906
Title: Re: Multileader Text Color Override not found in contents
Post by: steve.carson on February 06, 2019, 01:02:19 PM
Thanks Lee!
Title: Re: Multileader Text Color Override not found in contents
Post by: Lee Mac 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. )
Title: Re: Multileader Text Color Override not found in contents
Post by: ahsattarian 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. )