Author Topic: Error when trying to read object property - Multileader Background Mask  (Read 1197 times)

0 Members and 1 Guest are viewing this topic.

gumbtg

  • Mosquito
  • Posts: 12
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
Code: [Select]
(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)




Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Error when trying to read object property - Multileader Background Mask
« Reply #1 on: October 23, 2020, 09:18:29 AM »
You can check the contenttype property of the Multileader, e.g.:
Code - Auto/Visual Lisp: [Select]
  1. (= acmtextcontent (vla-get-contenttype <mleader-object>))

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Error when trying to read object property - Multileader Background Mask
« Reply #2 on: October 26, 2020, 11:16:18 AM »
You can check the contenttype property of the Multileader, e.g.:
Code - Auto/Visual Lisp: [Select]
  1. (= acmtextcontent (vla-get-contenttype <mleader-object>))
Speaking of mleader content, did you ever come across a way to set rotation for multileaders with blocks instead of text?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

gumbtg

  • Mosquito
  • Posts: 12
Re: Error when trying to read object property - Multileader Background Mask
« Reply #3 on: October 26, 2020, 12:00:11 PM »
You can check the contenttype property of the Multileader, e.g.:
Code - Auto/Visual Lisp: [Select]
  1. (= acmtextcontent (vla-get-contenttype <mleader-object>))

Thank you Lee. You remain my hero. Never knew about this approach.