Toggle mask fror mtext to work on mleaders too?

Toggle mask fror mtext to work on mleaders too?

DC-MWA
Collaborator Collaborator
1,040 Views
7 Replies
Message 1 of 8

Toggle mask fror mtext to work on mleaders too?

DC-MWA
Collaborator
Collaborator

Good morning,

I have a cool littl lisp that toggles the background mask on/off for selected mtext objects.

Wondering if anyone has something similar that will work on Mleaders as well? Or maybe a toggle lisp for mleaders that I can add to this routine to get what I'm looking for.

I have attached the lisp file.

 

Thanks!

0 Likes
Accepted solutions (1)
1,041 Views
7 Replies
Replies (7)
Message 2 of 8

CodeDing
Advisor
Advisor

@DC-MWA ,

 

I have this one laying around. Should do the trick.

 

EDIT:

I was perhaps a bit hasty. My approach merely APPLIES a background mask. It does not toggle. Maybe I can configure something new real quick...

 

EDIT 2:

Ok, I have updated the code below to TOGGLE. Give that a go.

 

(defun c:BM ( / ss e cnt)
  (prompt "\nSelect objects to toggle background mask: ")
  (if (setq ss (ssget '((0 . "MULTILEADER,MTEXT"))))
    (progn
      (repeat (setq cnt (sslength ss))
        (setq e (ssname ss (setq cnt (1- cnt))))
        (if (eq "MTEXT" (cdr (assoc 0 (entget e))))
          (progn
            (setpropertyvalue e "BackgroundFill" (abs (1- (getpropertyvalue e "BackgroundFill"))))
            (setpropertyvalue e "UseBackgroundColor" (abs (1- (getpropertyvalue e "UseBackgroundColor"))))
          );progn
          (setpropertyvalue e "MText/BackgroundFill" (abs (1- (getpropertyvalue e "MText/BackgroundFill"))))
        );if
      );repeat
      (command "_.REGEN")
      (prompt "\nBackground Masks have been Toggled.")
    );progn
  ;else
    (prompt "\nMust select either a Multileader or MText.")
  );if
  (setq ss nil)
  (princ)
);defun

Best,

~DD

0 Likes
Message 3 of 8

DC-MWA
Collaborator
Collaborator

Thank you...

This is what I was looking for. How hard is it to make toggle on/off?

0 Likes
Message 4 of 8

CodeDing
Advisor
Advisor
Accepted solution

@DC-MWA ,

 

I updated the code, please check again.

 

 Best,

~DD

0 Likes
Message 5 of 8

DC-MWA
Collaborator
Collaborator

Perfect!

Thank you so very much. You gurus always amaze me with your knowledge and skills.

 

Have a great weekend!!!

 

 

0 Likes
Message 6 of 8

pbejse
Mentor
Mentor

@DC-MWA wrote:

.. has something similar that will work on Mleaders as well? Or maybe a toggle lisp for

Thanks!


Here you go

 

(defun c:BM (/ ss e i prop)
  (if (setq ss (ssget ":L" '((0 . "MULTILEADER,MTEXT"))))
    (repeat (setq i (sslength ss))
      (setq e (ssname ss (setq i (1- i))))
      (setpropertyvalue
	e
	(setq prop
	       (if (eq (getpropertyvalue e "LocalizedName") "MText")
	  		"BackgroundFill" "MText/BackgroundFill" )
	  )
	  (boole 6 1 (getpropertyvalue e prop))
	)
      )
    )
  (princ)
)

 

HTH 

Message 7 of 8

ccnoah
Observer
Observer

When I run this on MTEXT entities, to toggle on the background mask, it is using fill color 200,200,200 for the background color.  Anyway to have it force "use drawing background color" ?

 

thank you

0 Likes
Message 8 of 8

ccnoah
Observer
Observer

okay, figured out if i comment out this line, it works like i want.

 

(setpropertyvalue e "UseBackgroundColor" (abs (1- (getpropertyvalue e "UseBackgroundColor"))))

 

0 Likes