AutoCAD/Layers in Xref

Advertisement


Question
I'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.

Answer
I 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

AutoCAD

All Answers


Answers by Expert:


Ask Experts

Volunteer


Bill DeShawn

Expertise

I can address all 2-D questions and some 3-D questions. I do programming in AutoLISP if it doesn`t involve solid modeling. I can also address menu customization issues and can help you find answers to questions I can`t answer by taking your question directly to Autodesk via their newsgroups.

Experience

I used to do electronic and mechanical design for a flat panel monitor manufacturer, and now I do architectural drafting for an architect. I did and do AutoLISP and menu customization and take pride in making my lisp routines to do the work exactly the way the client likes them done.

Publications
I had a routine published in CADENCE magazine (no longer in publication and taken over by CADALYST). Some of my routines are published on my website at http://my.sterling.net/~bdeshawn

©2012 About.com, a part of The New York Times Company. All rights reserved.