AutoLisp For Masking Mtext & Multileaders
I am attempting to create an AutoLisp routine that will "Create BricsCAD autolisp called “MLM”, for selected text and multileaders, set background mask to yes and set fill color to use drawing background color, and border offset factor to 1.25".
Using Gemini, I'm able to create a lisp that will mask both types, only the fill color is not the drawings background, and the border offset factor doesn't change from 1.5.
Any help? Please.
Comments
-
Hi.
See code below of setting Mtext border offset (DXF code 45) and background color (DXF codes 90 & 63).
(vla-put-backgroundfill theMText :vlax-true)
(setq dxf_ent (entget (entlast)))
(entmod (append dxf_ent '((90 . 3) (63 . 9) (421 . 13158600) (45 . 1.2) (441 . 0))))run google search on "cad mtext dxf code 90",
and also "cad entmake mtext" - that will give you resaults on how to create Mtext and set the DXF codes.
0 -
aridzv,
Thank you for your input. However, I personally do not know how to write lisp code, so I use AI. I do not know where I would add your code in the routine I've already created. Below is the code I created (MS Copilot 365 actually). If you would include your code my code where it belongs, I would be thankful. Attached is an image of what my code does.
(defun c:MLM ( / ss i ent obj)
(vl-load-com)(prompt "\nSelect TEXT, MTEXT, or MULTILEADERS: ")
(setq ss (ssget '((0 . "TEXT,MTEXT,MULTILEADER"))))(if ss
(progn
(setq i 0)
(while (< i (sslength ss))
(setq ent (ssname ss i))
(setq obj (vlax-ename->vla-object ent))(cond
;; MTEXT
((= (vla-get-objectname obj) "AcDbMText")
(vla-put-BackgroundFill obj :vlax-true)
(vla-put-UseBackgroundColor obj :vlax-true)
(vla-put-BackgroundScaleFactor obj 1.25)
)
;; TEXT (convert to use background mask if supported)
((= (vla-get-objectname obj) "AcDbText")
;; Some versions require setting via DXF
(entmod
(append (entget ent)
'((90 . 1) ; background fill on
(63 . 0) ; use drawing background
(45 . 1.25)) ; offset
)
)
)
;; MULTILEADER
((= (vla-get-objectname obj) "AcDbMLeader")
(vla-put-TextBackgroundFill obj :vlax-true)
(vla-put-TextUseBackgroundColor obj :vlax-true)
(vla-put-TextBackgroundScaleFactor obj 1.25)
)
)
(setq i (1+ i))
)
(prompt "\nBackground mask applied.")
)
(prompt "\nNothing selected."))
(princ)
)0