Thursday, April 27, 2023

XREFs on Layer

Over the years supporting AutoCAD/Civil 3D, I have been asked, where are my XREFs?  Co-workers have placed the references on the current layers and turned off that layer. I wrote a simple lisp routine that will place the reference on a specified called "G-ANNO-REFR" which can be changed to your company standards.

The lisp routine uses the "XA" command (which can be changed to your likings). XA is a default command for XATTACH. Once the lisp routine is set in the CUI startup, it will override the default "XA" command. Run the XA command to attach a drawing. Once the drawing is attached, the previous layer will be restored.


Items in red can be changed per user preference.

;SETS LAYER G-ANNO-REFR CURRENT BEFORE
;ATTACHING A DRAWING
;
;
(defun C:xa ()
   (command "layerpmode")
   (command "on")
   (command "-layer")
   (command "m")
   (command "G-ANNO-REFR")
   (command "")
   (initdia) (command "_XATTACH")

   (command "_layerp")
  
   (princ)
)



2 comments:

  1. Try using the XREFLAYER setting. I think this was added in the 2020? version. Whatever XREFLAYER is set to "G-ANNO-REFR", all future xrefs will be put on that layer, even if it isn't current.

    ReplyDelete