[Search tip detail and code files using keywords, tip number, author name, etc ]
 
Layer Macros
Tip# 3145 By Allan Erickson On 08-Feb-2009
2.5
Rated By 2 users
Categories : Programming Examples, Misc. User Tools, Layer Tools
Software type : AutoCAD
Rename File To : No Files to download.
Here are several macros for working with xref layers and one to find lost objects that were just created.

Allan Erickson sent us several macros that he uses when working with xref layers and one he uses to find lost objects that were just created.  He has several xrefs loaded into his drawings to obstructions but the drawing becomes so busy he can't see to work. "Unloading the xrefs or freezing the layers they are on constantly ate up a lot of time, so I created an AutoLISP shortcut to toggle them off and on."

All xrefs are placed on locked (to prevent accidental movement) layers with names that begin with 0X- or 0Y-.
The 0X- layers contain our 3D models and the 2D architectural base sheets.
The 0Y- layers contain the consulting engineers' contract drawings that we use as a map.
To remove or restore either group of xrefs from my busy monitor, I use the following commands to call small macros in single-line LISP routines:

FX = Freeze layers that begin with 0X-
TX = Thaw layers that begin with 0X-

FY = Freeze layers that begin with 0Y-
TY = Thaw layers that begin with 0Y-

To control xrefs individually I freeze/thaw using a layer filter with names 0X-* and 0Y-* or use the x-ref manager.

Typical names of our layers that hold xrefs:

0X-BASE-1
0X-BASE-2
0X-CLG-1
0X-DUCT-2
0X-PIPE-1
0X-PLMB-0
0X-PLMB-1
0X-SPKR-1
0X-STRUC
0Y-ED-1 (Engineers Duct w/o walls)
0Y-EH-1 (Engineers HVAC Piping w/o walls)

To work with all of these xrefs sanely, Visretain must be set to 1. That makes knowledge of "layer filters" and "maxsort" a must.

Here is the simple LISP code:

(defun c:FX ()
(command "_layer" "_freeze" "0x-*" "")
)

(defun c:TX ()
(command "_layer" "_thaw" "0x-*" "")
)


(defun c:FY ()
(command "_layer" "_freeze" "0Y-*" "")
)

(defun c:TY ()
(command "_layer" "_thaw" "0Y-*" "")
)

While on the subject of simple code, sometimes our third-party software will throw a 3D pipe fitting "somewhere" in the drawing. I know it happened, but I don't know where.

I use this LISP routine to hunt it down. I call it Zoom Last.

(defun c:ZL ()
(command "_.zoom" "_object" (entlast) "")
)


NOTES FROM CADALYST TIP PATROL:  Managing layers from referenced files can be time consuming.  This is a good routine that can help.  I have seen many firms rename the layers of outside-produced files to help manage them much like the example above.  That is a good idea too, but can cause problems in an xref.  To use these macros, open up Notepad and then copy/paste them into it.  Save the file and make sure it has an .LSP extension.  Load it into AutoCAD with the APPLOAD command.  Each macro is a two-letter keystroke, TX, FX, TY, and FY as described above.  They will work only if there are layers in the drawing that start with 0X or 0Y.  If you use a different naming system, just edit the macros to fit your needs.   The zoom last macro will zoom to the last object that was created.  In order for it to work, you have to use it before you create another object in the file. Tested in AutoCAD 2009.

 

Average Rating:
2.5


User comments


Log In