AutoCAD/Layers in Xref
Expert: Bill DeShawn - 8/5/2006
QuestionI'm using Autocad 2005. How do you change the color in the reference files? I've tried to change the color in the Layer Property Manager, but still it won't change the color in the screen. Please Help. Thank you.
AnswerI can help.
Thank you for telling me what version of AutoCAD you are running (2005).
Here is some LISP code for a routine that I created for our XREFs Give it a try and see how it works for you.
(defun xlaerr (msg)
(if c:r (c:r) (redraw))
(if rgm (setvar "regenmode" rgm))
(setq *error* olderr)
(princ msg)
(command "_.undo" "_end")
(prompt ". Please try again.")
(command "_regen")
(setq *error* olderr)
(command "_.undo" "_end")
(princ)
)
(defun xlaprog ()
(setvar "regenmode" 0)
(prompt "Enter an option [Freeze/Thaw/Color]: " )
(setq opt (strcase (getstring)))
(if (= opt "F")
(progn
(setq lname (strcase (getstring T "Name of Layer to Freeze: ")))
(command "_.layer" "f" (strcat "*|" lname)"")
)
)
(if (= opt "T")
(progn
(setq lname (strcase (getstring T "Name of Layer to Thaw: ")))
(command "_.layer" "t" (strcat "*|" lname)"")
(setq defla (strcat "*|" lname))
(setq rg T)
)
)
(if (= opt "C")
(progn
(setq colr (getstring "Color number or name: "))
(if defla (setq lname (getstring T (strcat "Apply color to what layer" " <" lname ">? ")))
(progn
(setq lname (strcase (getstring T (strcat "Apply color to what layer?: "))))
(setq defla (strcat "*|" lname))
)
)
(command "_.layer" "c" colr defla "")
)
)
(if (/= opt "")(xlaprog)(princ))
)
(defun c:xla (/ rg)
(if defla (setq defla nil))
(setq rgm (getvar "regenmode"))
(command "_.undo" "_g")
(setq olderr *error* *error* xlaerr)
(xlaprog);sub-routine
(command ".layer" "t""0" "")
(command "_.undo" "_end")
(if rg (command "_regen"))
(if defla (setq defla nil))
(setvar "regenmode" rgm)
(setq *error* olderr)
(command "_.undo" "_end")
(princ)
)
Save the code in a file and call it XLA.LSP. Load with appload and run it by typing XLA at the command line. Don't use the weird layer name that AutoCAD creates. Use the normal layer name. The routine adds something to the search that takes care of that.
Keep in touch
Bill Deshawn
http://my.sterling.net/~bdeshawn