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) )
Thankyou. This will save lots of time going through changing all the colours to grey.
Works great!! However it will turn on any layers that have been turned off.Any way to prevent that?
I too would love to know if there is a way to not turn on all the layers in the process!
I too would love to know the solution!
Great routine! But it looks like the online source code is missing the backslash in front of the “n” characters at the beginning of the “entsel” and two “prompt” functions. I’m sure that the intent was to have the prompts displayed on a new line (“\n”) on the command line when running the routine.
Thank you John. I have updated the code
~Greg
Thanks. What’s the best way to revert to normal?
To Revert the Layers to display as they do in the XREFed file:
Use the command VISRETAIN and set it to 0 (zero).
Reload the XREF from the XREF Manager
Use the command VISRETAIN and set it back to 1
Note: VISRETAIN is a system variable is not a command, the reason I refer to it as a command is that you can change system variable in the commandline like a command.
so were i will get the lisp
WERE CAN I DOWNLOAD THIS LISP ?
Thanks! working well
Why I can’t Download Sir?
Simply open the notepad, copy the code all and save as and give name XR253.LSP.
Thanks you sir it Work but how to turn on layer sir
From the tool menu,
Tools, Toolbars, AutoCAD, layers (select layer)
from here you can turn it on your layers
Ck Novel, you can’t download this routine. You need to copy all the code below the animation near the top of this page, paste it into a blank page in a text editor and save it as XR253.LSP.
Works great! But if I want XREF colour 250 then what I want to do replace the 253 to 250?
That’s correct! Wherever you see 253 in the code, just replace it with 250 or whatever color number you would like to use. Any number from 0 to 255 will work.
All of the entities in the XREF have to be color BYLAYER, right?