;; XClipID.lsp [command name: XClipID]
;; To IDentify XCLIPped external references and show their clipping boundaries.
;; Draws red [see comment to specify different color] Polyline on current Layer
;; along clipping boundary of each Xref that has one, with global width 1% of
;; current view height [see comment to adjust width] for increased noticeability.
;; Kent Cooper, last edited 22 January 2015

(defun C:XC (/ *error* doc ss n xrdata xc base svnames svvals)

(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
(princ (strcat "\nError: " errmsg))
); if
(if svnames (mapcar 'setvar svnames svvals)); reset System Variables
(vla-endundomark doc)
(princ)
); defun - *error*

(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vla-startundomark doc)

(if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 410 (getvar 'ctab)))))
(progn ; then
(setq n (sslength ss))
(while (and (not xc) (> n 0)); haven't found one yet, nor reached end of selection
(if
(and
(setq xrdata (entget (ssname ss (setq n (1- n)))))
(assoc 1 (tblsearch "block" (cdr (assoc 2 xrdata)))); it's an Xref
(assoc 360 xrdata); possibly Xclipped
); and
(setq xc (assoc 360 (entget (cdr (assoc 360 xrdata))))); then --
; [nil if none] found nested 360 entry; stop loop
); if
); while
); progn
); if
(if xc
(progn ; then -- found at least one; add red Polylines to all
(setq
base (entlast); reference last object
svnames '(cecolor cmdecho); System Variable names
svvals (mapcar 'getvar svnames); current values
); setq
(mapcar 'setvar svnames '("red" 0)); <-- edit "red" if different color desired [in quotes even if numerical]
(command "_.xclip" "_all" "" "_polyline")
(while (setq base (entnext base))
(entmod (append (entget base) (list (cons 43 (/ (getvar 'viewsize) 100))))); <-- edit 100 for desired width
); while
(mapcar 'setvar svnames svvals); reset System Variables
); progn
(alert "No Xclipped Xref(s) found in current space."); else
); if

(vla-endundomark doc)
(princ)
); defun
(c:xc)