;;;Elise Moss ;;;www.mossdesigns.com ;;;This routine locates all xrefs that are not found and detaches them from the drawing (defun c:xref-det () ; first we select all xrefs in the drawing (setq xref-set (ssget "x" '((0 . "insert")))) (if (/= xref-set nil) ; make sure there are xrefs (progn ; find out how many there are (setq xref-count (sslength xref-set)) ; not all of them are xrefs...some are blocks ;;start the counter (setq counter 0) ; let's loop thru the list (while (< counter xref-count) ;; get the first item (setq xref-name (ssname xref-set counter)) ;;get entity data (setq xref-data (entget xref-name)) (setq name (cdr (assoc 2 xref-data))) (setq check-name (tblsearch "block" name)) (setq xref-status (cdr (assoc 70 check-name))) ; if xref-status = 4 then the xref is not found (if (= xref-status 4) (command "-xref" "detach" name) ) ; go on to the next xref (setq counter (+ counter 1)) ) ;end while ) ;end progn ) ; end if (alert "All Unfound Xrefs Have Been Detached!") ) ; end defun