Change XREF Layer Colors to One Color

This tutorial video AutoCAD for Mac: Navigating the User Interface demonstrates the user interface in AutoCAD for Mac.

Here is a great lisp routine that lets you simply select an XREF and change all of the XREF’s layers to a specific color (color 253 in this case).

This is useful in some of my work’s drawings because we work with existing conditions as an XREF to the “Proposed” design which is also an XREF. To make the “Proposed” drawing have a good contrast while both drafting and printing, we override the existing drawing XREF’s colors on color 253. With this LISP routine, we can easily do so in one click (as shown below).

~enjoy


;;; Changes the selected XREF's Layer color to AutoCAD Color 253 in the current drawing only
;;; Useful for Existing Base (E-Base) XREFs
(defun c:XR253	(/ xr1 xr2 xr3 xr4 xr5 xr6 tx1 tb1)
  (if (setq
	xr1 (entsel "nSelect Xref to change all layers to color 253: ")  ;; <--- Change color number as needed
      ) ;_ end of setq
    (progn
      (setq xr2 (entget (car xr1)))
      (setq tx1 (cdr (assoc 0 xr2)))
      (if (and (= tx1 "INSERT")
	  ) ;_ end of and
	(progn
	  (setq xr3 (cdr (assoc 2 xr2)))
	  (setq xr4 (tblsearch "block" xr3))
	  (if (setq xr5 (cdr (assoc 1 xr4)))
	    (progn
	      (setq xr6 (strcat xr3 "|*"))
	      (command "-layer" "c" "253" xr6 "")  ;;; <---Change color number as needed
	    ) ;_ end of progn
	    (prompt (strcat "n" xr3 " is not an X-Ref."))
	  ) ;_ end of if
	) ;_ end of progn
	(prompt "nNo valid XREF selected")
      ) ;_ end of if
    ) ;_ end of progn
    (princ " ...Nothing selected")
  ) ;_ end of if
  (princ)
) 
【Free Cad Drawings Download Center】