How to set border offset factor for background masking Mtext?
I would like to automatically set the border offset factor for masking my mtext, I didn't see it as a property. Here's the code I have so far.
Code:
(defun c:mt_mask (/ acaddocument mspace object)
(initerr)
(vl-load-com)
(setq acaddocument (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace acaddocument))
(setq object (car (entsel "\nSelect MTEXT Object: ")))
(setq object (vlax-ename->vla-object object))
;(vlax-dump-object object)
(vla-put-backgroundfill object 1)
(reset)
(princ)
)
(princ)
Re: How to set border offset factor for background masking Mtext?
Hi,
I can't found this property (neither the backgroun color) in ActiveX, but it can be done with DXF
Code:
(defun c:mt_mask (/ ent elst)
(setq ent (car (entsel "\nSelect MTEXT Object: ")))
(setq elst (entget ent))
(if (= "MTEXT" (cdr (assoc 0 elst)))
(entmod
(append
(vl-remove-if
(function
(lambda (x)
(or (member (car x) '(90 63 421 45))
(< 419 (car x) 440)
)
)
)
elst
)
(list
'(90 . 1) ; activate background color (2 for vport color)
'(63 . 1) ; background index color
'(45 . 1.5) ; background scale factor
)
)
)
)
(princ)
)
Re: How to set border offset factor for background masking Mtext?
Quote:
Originally Posted by
boesiii
I would like to automatically set the border offset factor for masking my mtext, I didn't see it as a property. Here's the code I have so far.
Code:
(defun c:mt_mask (/ acaddocument mspace object)
(initerr)
(vl-load-com)
(setq acaddocument (vla-get-activedocument (vlax-get-acad-object)))
(setq mspace (vla-get-modelspace acaddocument))
(setq object (car (entsel "\nSelect MTEXT Object: ")))
(setq object (vlax-ename->vla-object object))
;(vlax-dump-object object)
(vla-put-backgroundfill object 1)
(reset)
(princ)
)
(princ)
There's a routine in this thread called MTEXTMASK.lsp that's pretty handy and I think it does what you're looking for.
Re: How to set border offset factor for background masking Mtext?
Thanks I will try it.
Why wouldn't all the properties of an object be included in Active X?
Re: How to set border offset factor for background masking Mtext?
There is an Express Tool called "Enclose text with object" command TCIRCLE that gives you a choice to enclose with a circle, slot, or rectangle. then prompts you for offset distance. then variable or constant distances. It's not as fun as a Lisp routine, but why make a wrench if there is already one in the toolbox.
Re: How to set border offset factor for background masking Mtext?
I agree, Mtextmask.lsp works well, I have been using it for quite a while.
However, for the first time I had need to use the Trucolor background, which was an option in the lisp under "color". I does not seem to work for me, the mask does not take the RGB color I input (eg. 253,254,240). The mask always becomes yellow. Has anyone had the same problem?
Otherwise the border offset and basic color background works fine.
I tried it on AutoCAD 2005 and 2009.
Brian C
Re: How to set border offset factor for background masking Mtext?
This works for me. I use a 'Border Offset Factor' of 1.15
Code:
; Turns Background mask on/off
; Set 'Border Offset Factor' to 1.15
(defun c:BGtoggle (/ ss1 num cnt obj ent)
(setq ss1 (ssget '((0 . "mtext")))
num (sslength ss1)
cnt 0)
(repeat num
(setq obj (vlax-ename->vla-object (ssname ss1 cnt)))
(if(= (vlax-get-property obj 'BackgroundFill):vlax-true)
(vlax-put-property obj 'BackgroundFill :vlax-false)
(progn
(vlax-put-property obj 'BackgroundFill :vlax-true)
(setq ent (vlax-vla-object->ename obj)
elist (entget ent)
elist (subst (cons 45 1.15)(assoc 45 elist) elist)
)
(entmod elist)
); progn
)
(setq cnt (1+ cnt))
); repeat
(vl-cmdf "_draworder" ss1 "" "f")
(princ)
)
Re: How to set border offset factor for background masking Mtext?
Hi, Tom.
I don´t know much about lisp, but I kind of figured out how to use part of your code to set a background color fill to all mtext selected... but I would like to bring all objects in layer Dims to front after I bring front selected background masked mtext...
I found this thread in another forums but it is normal lisp... Would it be possible to add this feature to your code..
I can see that you used the
(vl-cmdf "_draworder" ss1 "" "f")
So, How could I add something like this... after that order in your lisp?
Code:
;; Moves all objects on the "dims" layer to the back
(defun layf ()
;; creates a selection set of all objects on the "dims" layer.
(setq sel1 (ssget "x" '((8 . "dims"))))
;; Uses the draworder command to move the objects to the back
(command "draworder" sel1 "" "front")
)
--------------------
Nevermind... I figured that out...
and actually is the first time I found the way to add different types of selection sets and different commands to those selection sets...
Re: How to set border offset factor for background masking Mtext?
In response to Tom Beauford,
I used BGtoggle, and it works great! I don't know much about Autolisp, but could this be modified to change regular text to mtext if it is not already, and then proceed with the rest of the command? That would be great.
Re: How to set border offset factor for background masking Mtext?
Quote:
Originally Posted by
tommcgtx
In response to Tom Beauford,
I used BGtoggle, and it works great! I don't know much about Autolisp, but could this be modified to change regular text to mtext if it is not already, and then proceed with the rest of the command? That would be great.
You're probably better off just using the Express Tool TXT2MTXT first. That way you can group TEXT lines together that belong in one MTEXT and keep others as seperate MTEXTs. Once it ran and returned MTEXT with background there would be no way to know if it started as TEXT or MTEXT.