;;  XRLC.LSP                                       ;  Scot Harris  11-2-2011
;;   X-Ref Layer Change. Gathers all xrefs in the drawing file and moves
;;   these objects into a user specified layer.
(defun c:XRLC ( / a d n s )
(if (not (tblsearch "layer" "0-xref"))
(entmake
(list
(cons 0 "Layer")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbLayerTableRecord")
(cons 2 "0-xref")
(cons 70 0)
(cons 62 7)
(cons 6 "Continuous")
)
)
)

(setq s nil d nil n 0)
(setq a "0-xref")
(if (= a "") (setq a "0") );if
(if (tblsearch "LAYER" a)
(progn
(while (setq d (tblnext "BLOCK" (not d)))
(if (assoc 1 d)
(progn
(setq s (ssget "x" (list (cons 0 "INSERT") (assoc 2 d) )))
(setvar "CMDECHO" 0)
(command ".chprop" s "" "Layer" a "")
(setvar "CMDECHO" 1)
(setq n (+ n (sslength s)) s nil)
);progn
);if
);while
(if (> n 0)
(princ (strcat
"\n " (itoa n) " X-Ref object(s) moved to layer \"" (strcase a) "\". "))
(princ "\n No X-Ref objects found in this file. ")
);if
);progn
(princ (strcat
"\n Specified layer \"" (strcase a) "\" not found in this file. "))
);if
(setq a nil d nil n nil)(princ)
);endXRLC
(c:XRLC)

Advertisements