I have some code that is meant to search through xrefs in a drawing, and if it finds one xref with particular text, I'd like to extract some other text from that same xref's name.
Code:
(defun C:CUS-PAGE-CONFIG (/ activedocument xrefs xref psetup psize)
;
(vl-load-com)
(setq activedocument (vla-get-activedocument (vlax-get-Acad-Object)))
;
(setq xrefs (vla-get-blocks activedocument))
;
(vlax-for item xrefs ;looking through xrefs
(setq yesxref (vlax-get-property item 'isXref))
(if (= yesxref :vlax-true)
(setq xref (vlax-get-property item 'Name))
);if
);vlax-for
;
(if (wcmatch (strcase xref) "*TBLOCK*") ;if any xref matches TBLOCK then setq psize
(setq psize (substr xref 10 2))
);if
; ... (rest of code not important)
)
It seems to work fine for when there is only one xref in the drawing, but as soon as there are more, I'm told "Error: bad argument type: stringp nil".
Any help would be greatly appreciated.