PDA

View Full Version : multileader background fill


parkerfeldman
2009-03-19, 09:05 PM
Hello i wrote a routine that gets all multileaders and all mtext in the drawing and turns the background fill on or off. when the routine is run i get the error "; error: Automation Error. Description was not provided." i figured out that the issue is some multileaders do not have text so in the dump of the object it says "textbackgroundfill = exception occurred" how can i have it test if the multileader has text or have it test that the vla-get-textbackgroundfill must have a true or false value?

on another note like i said this routine does multileaders and mtext it has to ssget's
(setq ssml (ssget "X" (list (cons 0 "MULTILEADER"))))
(setq ssmt (ssget "X" (list (cons 0 "MTEXT"))))
it does not work when there is no mtext or no multileader in the drawing. how can i have it perform the ssget and set the value to nil if it is nil?

my code

(defun All (toggle /) ;tf ssml ssmt i obj)
(vl-cmdf "ZOOM" "E")
(setq ssml (ssget "X" (list (cons 0 "MULTILEADER"))))
(setq ssmt (ssget "X" (list (cons 0 "MTEXT"))))
(setq i (- 1))
(setq mlc 0)
(setq mtc 0)
(repeat (sslength ssml)
(setq
obj (vlax-ename->vla-object (ssname ssml (setq i (1+ i))))
)
(setq tf (vla-get-textbackgroundfill obj))
(if (/= tf toggle)
(progn
(vla-put-textbackgroundfill obj toggle)
(setq mlc (1+ mlc))
) ;_end progn
) ;_end if
) ;_end repeat
(setq i (- 1))
(repeat (sslength ssmt)
(setq
obj (vlax-ename->vla-object (ssname ssmt (setq i (1+ i))))
)
(setq tf (vla-get-backgroundfill obj))
(if (/= tf toggle)
(progn
(vla-put-backgroundfill obj toggle)
(setq mtc (1+ mtc))
) ;_end progn
) ;_end if
) ;_end repeat
(if (= toggle :vlax-true)
(setq onoff "ON")
(setq onoff "OFF")
)
(vl-cmdf "ZOOM" "P")
(princ "\n")
(princ mlc)
(princ " MULTILEADER BACKGROUND FILL ")
(princ onoff)
(terpri)
(princ mtc)
(princ " MULTITEXT BACKGROUND FILL ")
(princ onoff)
) ;_end All

mweaver
2009-03-23, 01:59 PM
Hello i wrote a routine that gets all multileaders and all mtext in the drawing and turns the background fill on or off. when the routine is run i get the error "; error: Automation Error. Description was not provided." i figured out that the issue is some multileaders do not have text so in the dump of the object it says "textbackgroundfill = exception occurred" how can i have it test if the multileader has text or have it test that the vla-get-textbackgroundfill must have a true or false value?

on another note like i said this routine does multileaders and mtext it has to ssget's
(setq ssml (ssget "X" (list (cons 0 "MULTILEADER"))))
(setq ssmt (ssget "X" (list (cons 0 "MTEXT"))))
it does not work when there is no mtext or no multileader in the drawing. how can i have it perform the ssget and set the value to nil if it is nil?



You will need something like this on your selection sets:
(if (and
ssml ;the selection set exists
(< 0 (sslength ssml)) ;it contains something
)


Now, about your automation error, you can normally use vl-catch-all-apply and vl-catch-all-error-p to capture automation errors. However, I'm using the beta for 2010 and vla-get-textbackgroundfill fails on a valid mleader with text when wrapped in a vl-catch-all-apply. It shouldn't. I get no error, no return value, nothing. This should have returned either an error, which I could handle with vl-catch-all-error-p, or the value for the property.

I will check this when I get to a machine running 2009 and see what I get for results there.

Later,
Mike Weaver

mweaver
2009-03-23, 04:30 PM
vl-catch-all-apply works as expected in 2009, so you can do something like:

(if (vl-catch-all-error-p (setq tf (vl-catch-all-apply 'vla-get-textbackgroundfill (list obj))))
;do this because there was an error getting the background fill property
;do this because there was no error
)


Hope that helps,
Mike