Depending on the purpose of your cleanup, there may be variety of tasks that you need to perform with the layers:
Task 1.The objects in the drawing are not on the correct layers, and you need to sort them out.
This is a manual process which you have to perform on every file individually. Before you start cleaning up, save the layers state and export it to an external text file. This way you do not have to worry about restoring status quo if you make a mistake. In addition, do not forget about Layer Previous.
Most of the tools you need to sort the content into the correct layers are contaoned in LAYERSII toolbox
My favorite tool for individual layer diagnostic and cleanup is LAYWALK. LAYISO and LAYUNISO could be used as well.
If you can identify criteria for sorting elements to layers (for example: all red elements should go to layer RED, or all blocks – go to layer BLOCKS) you can script that process or at least use QSELECT or selection filters.
Task 2. You need to show/plot XREFs with different symbology (color, lineweight, linetype).
When you approach this task, there are several things to consider:
- Are element properties (color, lineweight, linetype) of XREF files set ByLayer? If desired, you can use script to force ByLayer
- What is the VISRETAIN variable setting in the parent(s) file? If desired, script set VISRETAIN
VISRETAIN is a variable which controls if the parent file “remembers” changes to XREF dependent layer properties between AutoCAD sessions. VISRETAIN is saved in the drawing. When VISRETAIN =1 in the parent file and you attach (or overlay) an XREF for the first time, AutoCAD creates an internal lookup table in the parent file. This table contains all XREF dependent layers names and their properties as read from the XREF at the time of attachment. When you change XREF dependent layer properties, the internal lookup table holds these changes (only if VISRETAIN =1). If you add layers to the XREF file, a new record with information about the new XREF layers will be added to the table when XREF is reloaded.
- Are the XREFs already attached?
- Do you expect updates for the XREFs? If yes, do you expect the layers to be consistent?
Example: Site.dwg is your architectural site plan (VISRETAIN=1). You attached Surv.dwg (survey data) to it and changed properties of all XREF dependent layers from Surv.dwg to gray thin lines (true color 120,120,120, lineweight 0.18mm). Later you receive an update from the surveyor, and there is a new layer “ParkingLOT” (blue, 0.35mm) in the updated Surv.dwg. When you substitute the old version of Surv.dwg with the new one, all XREF dependent layers except ParkingLOT will remain gray and thin, ParkingLOT will be blue and 0.35mm
If you now set VISRETAIN =0 in the Site.dwg, the lookup table will not be saved. Next time you open Site.dwg, the XREF dependent layers properties will be re-read from the XREF file. If you now set VISRETAIN =1 in the Site.dwg, it will not return to your gray thin lines, you will need to re-assign the properties again.
VISRETAIN controls all XREFs together, it cannot control individual XREFs.
When you have multiple similar files with multiple similar XREFs which have the similar file names and identical layer names, you can use some tricks to speed up repetitive tasks.
Super Trick: Say you are working on a hi-rise building (30 floors). File names for all floors follow the naming convention filename-NN.dwg where NN represents floor number. Layers names are identical for all floors.
The layers states (on/off, symbology and freeze status) should be similar for all floors. It would really save you a lot of time if you can set up the layer state for one floor, and then use it for the another 29. The problem is that XREF dependent layer names for different floors have different names because they contain the floor number.
Here is what you can do:
- Set up the layers the way you want them for one of the floors; in this example, I use 01.
- Name and save the layer state and export it to an external file Floor1.las
- Open Floor1.las in any text editor and replace “-01” with “-02”, then save as Floor2.las
- You now can import and apply Floor2.las to the second floor.
Task 3. You need to change layer properties without changing layer names.
Most common reason to change layer properties is to make them work with a different CTB.
You can use Standards Checker to automatically fix layer properties if the layer names are identical.
If you have a “good” drawing with the layers properties the way you want them, you can save it as a .dws file and use with Standards Checker (Tools->CAD Standards)
You may want to associate standards files with the drawings after they have been cleaned up to catch future deviations before they accumulate.
Task 4. You need to migrate the files from one layer naming standard to another.
The best AutoCAD tool for this job is Layer Translator.
LAYTRANS from command line or Tools->Cad Standards->Layer Translator from the menu.
Layer translator allows you to create a “translation table” which maps the layers from your file to the layers of another .dwg or .dws file. They can be saved and re-used on other files.
Tips on using LAYTRANS:
- Clean up Layer 0 and Defpoint layer first. Then Map same. That will take care of the layers with identical names
Zoom Extents before you start Layer Translator.
- In Settings check Show layer contents when selected. That will visually isolate selected layers display. Use Selection Filter if needed.
- Map the layers that you can visually identify first. Save the Layer Translation Mappings. Translate.
Use LAYWALK and other layer tools as described in task1 to clarify and sort out messed up layers, then go back to translation
Limitations of LAYTRANS:
- Works on one file at a time. Cannot batch translate multiple files.
Even when all options are selected, the nested objects in blocks are NOT forced to color and linetype ByLayer. Use SETBYLAYER in AutoCAD2008-2009.
- Missing features: options to Force object Lineweight and Plotstyle to ByLayer.
- Can’t zoom in/out while in Layer Translator
- Layer Descriptions will be lost in translation.
Using “Other Software” for batch processing of layers and other tasks
MicroStation translation tables are Excel files, and can be easily edited for such tasks as renaming layers by appending, pre-pending and partial name substitution. You can also force color, linetype and lineweight to ByLayer for the objects nested in blocks
Best of all, MicroStation can batch translate layers in multiple files. Use latest versions for compatibility with latest AutoCAD file format.
Potential problems to watch for while cleaning up layers
Special layers. No graphic elements should be on Layer 0 or Defpoints.
- A layer is identified by its name, and when the name is changed, other files this file is referenced to (parent files) are not ”aware” of that change.
If you change XREF dependent layer names, the XREF dependent layers properties specifically assigned in the parent file using VISRETAIN=1 will stop working.
Similarly, when you rename XREF layers, the freeze and on/off (and for 2008 VP symbology settings) information in the plot sheet will be lost. In addition, this layer may need to be reconciled.
If you use layer states and export them outside of your drawing file, after renaming the layers the exported layer states will be unusable.
- Always keep in mind that color, lineweight and, in many cases, linetype and plot style for graphic objects are set to “ByLayer”, so any change to layer properties has to be coordinated with the plot style table you are going to use.
- In previous versions of AutoCAD you could only assign VP Freeze to a layer. Now in addition you can assign VP Color, VP Linetype, VP Lineweight and, for the DWG of STB flavor, VP Plot style. In other words, your layers may look and plot differently in different viewports.