Occasionally we run into a failure on a file to bind its XREF's because an XREF contains a block with the same name as an XREF. Unfortunately AutoCAD never mentions which object name so it can be updated. It is a mistake clients make occassionally.
Has anyone ever looked at fixing this with a routine automatically?
I am fiddling with some of the block routines you good folks shared with me last week.
I wondered where I would catch the error for the XREF having the same name as a block or nested block that could cause the failure?
(defun c:xrb ()
(vl-load-com)
(vlax-for Obj (vla-get-Blocks
(vla-get-ActiveDocument
(vlax-get-acad-object)))
;; Get hold of the block collection for
;; the active document and iterate through it.
;; Note:-
;; To make the program faster, set the ActiveDocument Object
;; to a variable defined in the main function, and use it in
;; the sub-function to save calling vlax-get-acad-object multiple
;; times.
(if (eq :vlax-true (vla-get-IsXRef Obj))
;; Check Block is an XRef
(if (vl-catch-all-error-p
(vl-catch-all-apply 'vla-bind (list Obj)))
;; Use vl-catch-all-apply to trap any errors that
;; may occur, and prevent program from crashing!
(alert
;(princ
(strcat "\n** " (vla-get-Name Obj) " Failed to Bind **"))))
)
;; Notify of an error during reloading.
(princ "\n XREF reloading complete!!!\n")
(princ)
)