Hatch and mtext background mask

Hatch and mtext background mask

kzD1219
Collaborator Collaborator
1,710 Views
6 Replies
Message 1 of 7

Hatch and mtext background mask

kzD1219
Collaborator
Collaborator

Here is the situation...We create a plan with mtext and linework, the requirement is to submit the plan with no color and then a plan showing color (which represents different things).  The way we have been doing it is saving the original no color drawing and then adding the colored solid hatch and changing and background mask colors to match the color of the hatch in the area it is in.  I am attaching an example of a no-color plan, the in between stage and the final color plan.  

 

What I am looking for is to not have to create 2 separate plans because of changes come back they have to be made to 2 dwg files, not just one.  I am not interested in xreferences for this type of project, but still don't think that would solve any issue either.

 

Anyone can easily turn off and on the color hatch layers, that isn't a big thing, but changing the mtext background mask is the issue because in the no color plan, the lines behind the mtext need to be hidden, but with the color, the lines need to be hidden and be the correct hatch color. 

 

Every time we print out a no color plan and then color plan, I would be wasting time changing the mtext mask color back and forth, needless to say some could get missed as well. It is also wasting time making changes in 2 drawings instead of 1 obviously.  

 

Is there any way to have the drawing hatched, but when printing the no color plan, not show the color and just show a black background mask on the mtext?  Separate ctb files?  

 

Looking to find new ideas for an inconvenience we have with these requirements.  

0 Likes
1,711 Views
6 Replies
Replies (6)
Message 2 of 7

dlanorh
Advisor
Advisor
I cannot open your drawing. Can your attach in AutoCAD 2010 Format?
It's possible to change the background mask color by modifying the mtext data, but i'm not sure about toggling between two states as there is no way to know what the color was without saving the color value somewhere.

I am not one of the robots you're looking for

0 Likes
Message 3 of 7

kzD1219
Collaborator
Collaborator

Here is the 2010 version.  Hope that helps show you what I am up against.  The making correction is killer when there are 2 drawings.

0 Likes
Message 4 of 7

ВeekeeCZ
Consultant
Consultant

Maybe multiple toggle Use Background Color option?

 

(defun c:MtextBackgroundColorOn (/ ss i)

  (if (setq ss (ssget "_X" (list '(0 . "MTEXT") (cons 410 (getvar 'CTAB)))))
    (repeat (setq i (sslength ss))
      (setpropertyvalue (ssname ss (setq i (1- i))) "UseBackgroundColor" 1)))
  (command "_.regen")
  (princ)
  )



(defun c:MtextBackgroundColorOff (/ ss i)

  (if (setq ss (ssget "_X" (list '(0 . "MTEXT") (cons 410 (getvar 'CTAB)))))
    (repeat (setq i (sslength ss))
      (setpropertyvalue (ssname ss (setq i (1- i))) "UseBackgroundColor" 0)))
  (command "_.regen")
  (princ)
  )

Right now it applies change for all MTEXTs - you might want to remove "_X" from the code to allow user selection

0 Likes
Message 5 of 7

kzD1219
Collaborator
Collaborator

@ВeekeeCZ wrote:

Maybe multiple toggle Use Background Color option?

 

(defun c:MtextBackgroundColorOn (/ ss i)

  (if (setq ss (ssget "_X" (list '(0 . "MTEXT") (cons 410 (getvar 'CTAB)))))
    (repeat (setq i (sslength ss))
      (setpropertyvalue (ssname ss (setq i (1- i))) "UseBackgroundColor" 1)))
  (command "_.regen")
  (princ)
  )



(defun c:MtextBackgroundColorOff (/ ss i)

  (if (setq ss (ssget "_X" (list '(0 . "MTEXT") (cons 410 (getvar 'CTAB)))))
    (repeat (setq i (sslength ss))
      (setpropertyvalue (ssname ss (setq i (1- i))) "UseBackgroundColor" 0)))
  (command "_.regen")
  (princ)
  )

Right now it applies change for all MTEXTs - you might want to remove "_X"


So when trying that, when I turn the mtextmaskoff, it changes all the background mask colors to the colors of the mtext, turning it on again, looks to remove even the color background in the 'final color plan required' and then will look like the middle example.  Nice thought though.  

0 Likes
Message 6 of 7

ВeekeeCZ
Consultant
Consultant

Well, I thought it was the key issue that you're unable to solve.

But I can surely add one more line to control the fillmode. Not sure if that is the best way to go - turning the set of layers on/off would also work...

Then try and see...

 

(defun c:MtextBackgroundColorOn (/ ss i)

  (if (setq ss (ssget "_X" (list '(0 . "MTEXT") (cons 410 (getvar 'CTAB)))))
    (repeat (setq i (sslength ss))
      (setpropertyvalue (ssname ss (setq i (1- i))) "UseBackgroundColor" 1)))
  (setvar 'fillmode 0)
  (command "_.regen")
  (princ)
  )



(defun c:MtextBackgroundColorOff (/ ss i)

  (if (setq ss (ssget "_X" (list '(0 . "MTEXT") (cons 410 (getvar 'CTAB)))))
    (repeat (setq i (sslength ss))
      (setpropertyvalue (ssname ss (setq i (1- i))) "UseBackgroundColor" 0)))
  (setvar 'fillmode 1)
  (command "_.regen")
  (princ)
  )

 

0 Likes
Message 7 of 7

dlanorh
Advisor
Advisor

Try the attached lisp.

 

It is minimally tested in 2012. Hatches must have true colour. Colour book colours will error as will index colours, although adapting the lisp is possible.

 

MText selection is by ssget. Only MTexts will be selected so you can select individually, window or crossing

 

HATCH LAYERS THAWED

The lisp works by checking if there is a hatch underneath each mtext selected. If there is; it finds the hatch layer, finds the layer in the layer table and extracts the required true colour data. The current background mask colour data will be removed and it will append the new colour data to the list.

 

HATCH LAYERS FROZEN

No hatch patterns will be found and it will remove the current background mask colour data items and append the required colour = background colour data to the list.

 

 

I am not one of the robots you're looking for

0 Likes