I have a routine here that enables the background mask for both text and multileaders. However, multileaders do not always contain text, such as the case when a user block is used, in which case the background mask property does not apply. How can I handle this in the code below? I get an automation error with no description when I try to get the TextBackgroundMask property. And checking if it is available returns true so I cant filter out that object with this method either (vlax-property-available-p x "TextBackgroundFill" T).
When dumping a multileader with a block the TextBackgroundMask reads "Exception Occured". I have searched high and low and have not seen anything yet on how to handle this or how I can leverage my code to realize this object's property is not editable.
I tried to use a Vl-catch-all-apply before checking that property (when it fails and routine drops out). I must be using it wrong or its because it is inside of a lambda.
Full disclosure my Vlisp knowledge is limited.
Portion of code I am talking about is below. Full code is attached as file. Again the problem is with the multileader section only.
Thank you
(vl-load-com)
(AT:Undo "V" "B")
;; background offset setting
(setq #BackgroundOffset 1)
(cond
;; select mtext and multileaders
((setq #SSList
(AT:SS->List (ssget ":L" '((0 . "MTEXT,MULTILEADER"))) T)
) ;_ setq
;; something selected, time to process data
(mapcar
'(lambda (x)
(cond
;; mtext
((eq (vla-get-ObjectName x) "AcDbMText")
(if (eq (vla-get-backgroundfill x) :vlax-false)
(progn
;; set backgroundfill to true
(vla-put-backgroundfill x :vlax-true)
;; convert object to ename and entmod offset
(setq #Ent (entget (vlax-vla-object->ename x)))
(entmod (subst (cons 45 #BackgroundOffset)
(assoc 45 #Ent)
#Ent
) ;_ subst
) ;_ entmod
) ;_ progn
;; set backgroundfill to false
;(vla-put-backgroundfill x :vlax-false)
) ;_ if
)
;; multileader
((eq (vla-get-Objectname x) "AcDbMLeader")
(vlax-property-available-p x "TextBackgroundFill" T);can the property be modified?
(if (vl-catch-all-apply (eq (vla-get-TextBackgroundFill x) :vlax-false));tried to use error catching unsuccesfully here.
(progn
;; set background fill to true
(vla-put-TextBackgroundFill x :vlax-true)
;; convert object to ename and entmod offset
(setq #Ent (entget (vlax-vla-object->ename x)))
(entmod (subst (cons 141 #BackgroundOffset)
(assoc 141 #Ent)
#Ent
) ;_ subst
) ;_ entmod
) ;_ progn
;----else----- ;; toggle, set backgroundfill to false
;(vla-put-TextBackgroundFill x :vlax-false)
) ;end of if
);end of condition
) ;_ cond
) ;_ lambda
#SSList
) ;_ mapcar
)
) ;_ cond
(AT:Undo "V" "E")
(princ)