Author Topic: MLEADER Background mask offset values  (Read 3079 times)

0 Members and 1 Guest are viewing this topic.

Dave M

  • Newt
  • Posts: 196
MLEADER Background mask offset values
« on: April 11, 2012, 07:30:04 PM »
Has anyone ever seen a routine that would let you select multiple mleaders and manipulate the background mask options?  It would be nice to be able to turn them on or off, and also adjust the offset value, color, etc.

Lee Ambrosius wrote a handy routine for working with mtext objects, it would be nice if it also worked on mleaders.

Dave
Civil 3D 2018 - Microstation SS4 - Windows 10 - Dropbox

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: MLEADER Background mask offset values
« Reply #1 on: April 13, 2012, 07:40:22 AM »
Perhaps:
Code: [Select]
(defun c:MLBackground (/ on ss n ed)
  (or *MLBack* (setq *MLBack* "ON"))
  (if (progn (initget "ON OFF") (setq on (getkword (strcat "Turn [ON/OFF] <" *MLBack* ">: "))))
    (setq *MLBack* on) (setq on *MLBack*))
  (if (setq ss (ssget '((0 . "MULTILEADER"))))
    (repeat (setq n (sslength ss))
      (setq ed (entget (ssname ss (setq n (1- n)))))
      (foreach item (if (eq on "ON")
                      '((141 . 1.5) (291 . 1) (292 . 1))
                      '((141 . 0.0) (291 . 0) (292 . 0)))
        (setq ed (subst item (assoc (car item) ed) ed)))
      (entmod ed)))
  (princ))
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Dave M

  • Newt
  • Posts: 196
Re: MLEADER Background mask offset values
« Reply #2 on: April 13, 2012, 02:17:33 PM »
This works well, but I guess what I would really like is the ability to control the offset value.  Also, when I run the routine, it is turning on the text frame as well.

Thanks
Civil 3D 2018 - Microstation SS4 - Windows 10 - Dropbox

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: MLEADER Background mask offset values
« Reply #3 on: April 14, 2012, 05:46:01 AM »
Would you like to try and modify it yourself?

Tip: Make a leader, then run the code below (just paste into command-line) & select it. make a change to the leader manually and re-run the code below and again select it. Press F2 to display all the DXF codes. Compare the 2 to check what has changed.
Code: [Select]
(entget (car (entsel)))
I prefer using some decent text editor which allows comparison. Something like NotePad+ should do as it shows 2 files next to each other highlighting differences.

First, I can see that the 141 code governs the offset. Then the 291 code governs if the background is turned on / off. The 292 code governs if the background uses a blank-out or a colour. Changing the colour sets the 91 code, though this seems to be saved in RGB format.

Just be careful, as you've seen there's more than one of the same codes. E.g. the 1st 292 code is the blank-out on background, but the 2nd is the text frame. So rather than using the subst (which substitutes all items in the list matching an example) - it might be preferable to recreate the DXF list by stepping through it and only changing those which apply.

Then next to allow for asking for a offset, do somthing similar to what I did for the ON/OFF idea. Only this time use a getdist instead of a getkword.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: MLEADER Background mask offset values
« Reply #4 on: April 16, 2012, 01:43:08 PM »
This thread inspired me to write this program:

http://www.theswamp.org/index.php?topic=41512.0

 :-)