I have this old code I've been using for years and today one of our new guys wanted to know if there was a more elegant option for these functions. My first answer was "Surely", when he then asked "What are they?", I said "I dunno". So I thought I just ask you guys. Each one functions on the selected XREF's to either reload, unload or detach (no error check) tear 'em up, guys:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:xre ()
(prompt "\N Select Element in XREF to RELOAD ")
(xref-loader "reload")
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:xru ()
(prompt "\N Select Element in XREF to UNLOAD ")
(xref-loader "unload")
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:xrd ()
(prompt "\N Select Element in XREF to DETACH ")
(xref-loader "detach")
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun xref-loader ( xref-action / old setlgth co t2 temp blkname)
(command ".undo" "BEGIN")
(setvar "cmdecho" 0)
(setq
old (ssget)
setlgth (sslength old)
co -1
t2 "t"
)
(while (boundp 't2)
(progn
(setq
co (1+ co)
temp (entget (ssname old co))
blkname (cdr (assoc 2 temp))
t2 (ssname old (1+ co))
)
(command "-xref" xref-action blkname)
) ;; end progn
) ;; end while
(setq co (1+ co))
(princ)
(command ".undo" "END")
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;