When attempting to detach an xref from a main drawing, AutoCAD displays the error “Xref NAME has multiple references. Not detached.” This is caused by referencing the given xref multiple times into the drawing. It may appear when attaching an xref in paperspace (in layouts), by inserting it into a nested block (or nested xref – A xrefs B and C but C xrefs B), or when you have a block definition with the same name. Check your layouts and deleted/detach xrefs from there, purge unused blocks in the main drawing and in the complaining xref. Let say that you have 2 xrefs attached to your model, Xref1 and Xref2 if Xref2 has Xref1 attached and you try to detach Xref1 you get the message. model |____Xref1 |____Xref2—Xref1 you have to detach Xref 1 from Xref2 and then detach Xref1 from model. Maybe the reference was also saved in the file as a block?? Problematic Xref can be inserted as a block somewhere in either Model Space or one of the Paper Space tabs.
My (Igal Averbuh) Solution:
1. Create empty drawing: For example blank.dwg (no layers.. no blocks… empty!)
2. Change path to blank.dwg for “problematic” xref’s
3. Bind an XREF which has multiple instances
And now you have dan allen lisp for it! Modified by me in order to do it fast
(defun c:RepathUnloadedXrefs () (abc_RepathUnloadedXrefs nil)(princ))
(defun c:RepathUnloadedXrefsWithBlank () (abc_RepathUnloadedXrefs "blank.dwg")(princ))
(defun c:MRD () (c:RepathUnloadedXrefsWithBlank)(princ))
(defun-q abc_RepathUnloadedXrefs ( replacedwg / unlxrefs dwglist$ continue )
;; if preset replacement drawing provided, confirm it existings
(or ;(setq replacedwg (abc_FindFile_Library replacedwg))
(setq replacedwg (findfile replacedwg))
;; check for multiple references xrefs
(setq unlxrefs (abc_GetXrefUnLoaded)
;; if they existing, ask to confirm
(foreach x unlxrefs
(setq dwglist$ (strcat dwglist$ (car x) "\n"))
(setq continue (dos_msgbox (strcat "Repath the following multiple references xrefs:\n" dwglist$ (if replacedwg (strcat "\nWith this file: " replacedwg) "")) "Repath multiple references Xrefs" 2 4))
;; if replacement drawings not provided or found, ask for it
(if (and (not replacedwg)(= 4 continue))
(setq replacedwg (dos_getfiled
"Select a blank.dwg file or place this file to support path"
"Drawing files (*.dwg)|*.dwg|All files (*.*)|*.*||"
(if (and replacedwg (= 4 continue))
(foreach x unlxrefs
(command "-xref" "path" (car x) replacedwg)
(command "-xref" "reload" (car x))
(command "-xref" "bind" (car x))
(princ (strcat "\nDetached xref " (car x)))
(princ "\nFirst of all Place file blank.dwg to autocad support path \nand ONLY AFTER IT invoke this programm!")
(alert "\nFirst of all UNLOAD All Multiple References Xrefs \nand ONLY AFTER IT invoke this programm!")
(defun-q abc_GetXrefUnLoaded (/ block bname xlist) ;includes unresolved (unfound)
(while (setq block (tblnext "block" (not block)))
(cond ( (and (eq 4 (logand 4 (cdr (assoc 70 block)))) ;is this an xref?
(zerop (logand (cdr (assoc 70 block)) 32)) ; and is it not loaded?
(setq bname (strcase (cdr (assoc 2 block)) t))
(setq bc (cdr (assoc 70 block))) ; return actual bitcode
(setq path (strcase (cdr (assoc 1 block)) t))
(setq xlist (cons (list bname bc path) xlist))