Académique Documents
Professionnel Documents
Culture Documents
AU308-2
AutoCAD provides a wide variety of tools for manipulating and managing your layers. This class will provide an overview of these different tools and how to put them to good use. We'll discuss everything from the Layer dialog to Layer Walk as well as how to use the Layer Translator, Layer states, Layer notification and Viewport Layer overrides. Learn how these tools work and when to use them from one of the AutoCAD developers who implemented them.
Tom is the Global Technical Lead for AutoCAD Product Support. Prior to that, Tom was an Autodesk software developer for ten years working on the AutoCAD Development Team. His AutoCAD experience spans more than 20 years and includes production drafting, developing custom and commercial third-party AutoCAD add-on applications and, of course, implementing new features for AutoCAD. Tom has worked on many aspects of AutoCAD, is a frequent presenter at Autodesk University.
Management
LAYDEL Deletes object's layer LAYERP Undoes the last change or set of changes made to layer settings. LAYERPMODE Turns the tracking of changes made to layer settings on and off LAYERSTATE Saves, restores, and manages named layer states LAYERSTATESAVE Save a new layer state LAYTRANS Translates one layer scheme to another LAYWALK Dynamically displays objects on selected layers LAYLCK Locks object's layer LAYULK Unlocks object's layer PURGE Removes unreferenced layers from a drawing RENAME Change the names assigned to layers
Monitor
LAYERFILTERALERT Deletes excessive layer filters to improve performance. LAYEREVAL Specifies whether the layer list is evaluated for new layers when added to the drawing or to attached xrefs LAYEREVALCTL Controls the overall Unreconciled New Layer filter list in Layer Properties Manager LAYERNOTIFY Specifies when an alert displays when unreconciled new layers are found
Layer Manager
LAYER Manage layers and layer properties LAYERDLGMODE Sets the flavor of the Layer Properties Manager that is defined for the use of the LAYER command CLASSICLAYER Opens the modal Layer Properties Manager LAYERPALETTE Opens the modeless Layer Properties Manager LAYERCLOSE Closes the Layer Properties Manager if it is open. LAYERMANAGERSTATE Indicates whether the Layer Properties Manager is open or closed SHOWLAYERUSAGE Displays icons in the Layer Properties Manager to indicate whether layers are in use
Visibility
LAYFRZ Freezes object's layer LAYOFF Turns object's layer off LAYON Turns all layers on LAYTHW Thaws all layers LAYISO Isolates object's layer LAYUNISO Undoes the LAYISO command LAYLOCKFADECTL Controls the amount of fading for objects on locked layers ULAYERS Controls the display of layers in a DWF, DWFx, PDF, or DGN underlay DGNLAYERS Controls the display of layers in a DGN underlay. DWFLAYERS Controls the display of layers in a DWF or DWFx underlay. PDFLAYERS Controls the display of layers in a PDF underlay. VISRETAIN Controls the properties of xref-dependent layers
Viewport
LAYVPI Isolates object's layer to current viewport VPLAYER Sets layer visibility within viewports VPLAYEROVERRIDES Indicates if there are any layers with viewport (VP) property overrides for the current layout viewport VPLAYEROVERRIDESMODE Controls whether layer property overrides for layout viewports are displayed and plotted
As you can see by the preceding couple of pages, there are almost 50 different commands and system variables directly related to the assignment, management and manipulation of layers in AutoCAD. Since time and space does not permit me to explain each and every one of these commands and I dont want to just restate what you can read for yourself in the AutoCAD help docs Im going to focus on five key tools to help you with your layer management. These tools are a bit more complicated than features like LAYOFF and LAYFRZ but can really increase productivity and consistency when you know how to use them.
Layer Walk
The idea behind Layer Walk (LAYWALK) is being able to quickly inspect the contents of the layers in a drawing. For example, when you receive a drawing from an outside contractor or have to work in someone elses drawing, and just need to do a high-level inspection of the drawing contents. Even using a tool as quick as LAYISO would still involve isolating and un-isolating each layer ... one layer at a time. Layer Walk makes it quick and easy to see which objects reside on which layer. Using the dialog, you select the layers you want to view and the selected layers are isolated from the unselected layers so only the objects on those layers display. When you launch Layer Walk it automatically highlights, in the layer list, those layers that are currently visible in the drawing (or the viewport youre currently in). The effect is that there is no initial change to the layers being displayed and you can see in the list which layers those are. Also, the number of layers in the drawing are displayed in the dialog box title. To view an individual layer, you simply select the layer name in the list and it isolates that layer from all the unselected layers. When you select multiple layers, everything selected gets isolated. To make a selected layer stick (so that it continues to display even when it isnt highlighted in the list), you can double-click on the layer name or right-click in the list and pick Hold Selection. Once a layer is held it continues to display and you can select other layers to view in context of the held layers. By default, the Restore on exit option is checked, which restores the original visibility of layers when you exit Layer Walk. Un-checking this option will leave the selected (or held) layers visible when Layer Walk is closed. You can use the Layer Walk dialog box in a paper space viewport to select layers to turn on and thaw in the layer table and the current viewport. Any layer that is not selected in the layer list is frozen in the current viewport. This makes it very easy to change the display of one viewport without altering the display of another viewport.
Layer Translator
Layer Translator was developed to handle the complex task of translating drawings from one layer scheme to another. If youve ever received a drawing with a cryptic or otherwise useless layer naming convention (like number layers ... dont you just hate that?) you understand how important it is to have proper layer names and properties. Using Layer Translator, you specify the layers in the current drawing that you want to translate, and the layers to translate them to. The Translate From list shows the names of all the layers in the current drawing. You can select layers for translation by highlighting them in the list or by using a wild-card selection filter on the list. Each layer name has an icon that indicates whether or not a particular layer is actually referenced in the drawing. Unreferenced layers can be purged from the drawing (thereby immediately thinning your list of layers that need to be translated) by right-clicking in the Translate From list and choosing Purge Layers from the context menu. The Translate To list shows the list of layers you can translate the current drawing's layers to. This list can be populated using a couple different methods. The Load button lets you select a drawing, drawing template, or standards file that contains layers you want to use as your target translation layers. If need be, you can load layers from more than one file at a time (if you load a file that contains layers of the same name as layers already loaded, the original layers are retained and the duplicate layers are ignored - first in, wins). If you want to create a layer on-the-fly, picking the New button will display a dialog where you specify a new layer to be used in translation. If you select a layer in the Translate To list before choosing New, the selected layer's properties are used as defaults for the new layer. You cannot create a new layer with the same name as an existing layer.
The current mappings will show up in the Layer Translation Mappings list showing the old layer name, new layer name, and the properties that will be applied to the layer during translation. If you find that you need to change the destination properties before translation, you can select a layer mapping in the Layer Translation Mappings list and pick the Edit button to change those properties. If your list of destination layers includes layers with the same name as layers needing to be translated AND you know that the mapping of one to the other is correct, you can just pick the Map same button and it will automatically queue up layers with matching names for translation.
Translation Settings
The Settings dialog gives you a few more options over the layer translation process. The Force object color to ByLayer and Force object linetype to ByLayer options let you specify whether or not every object translated takes on the color or linetype assigned to its layer. This can be a quick way to fix those objects with forced properties so they display using the properties of the layer on which they reside. The Translate objects in blocks option lets you specify whether or not objects nested within blocks get translated during the layer translation process. If Write transaction Log is checked, Layer Translator will create a log file detailing the results of translation. The log file is automatically created in the same folder as the translated drawing and has the same name as the translated drawing, with a .log file name extension. As previously mentioned, the Show layer contents when selected option enables Layer Walk-like behavior to display the contents of selected layers.
LAYERSTATESAVE
There is an undocumented command named LAYERSTATESAVE that launches the New Layer State to Save dialog. Using this interface you can quickly save a new layer state (or replace an existing layer state) without having to launch either the Layer State Manager or the Layer Properties Manager.
At the file name prompt, enter the name of the drawing from which you want to import layer states. Then enter the name of the layer state you want; or use the default * option to import them all; or get a list of the available layer states with a ?.
When an xref containing layer states is attached to the host drawing, those layer states are also listed in the Layer States Manager (along with layer states from any nested xrefs). Xref layer states can be restored however they cant be edited or deleted. Xref layer states are given unique names to easily identify and separate them from host layer states. The xref layer state name is preceded by the xref drawings name, separated by a double underscore symbol, e.g., Site Plan__Landscaping. If the xref is bound to the host drawing, the double underscore is replaced with the standard $0$, e.g., Site Plan$0$Landscaping. Xref layer states are removed from the host drawing when the xref is detached or unloaded. To quickly hide xref layer states in the Layer States Manager, check the Dont list layer states in xrefs option. The xref layer states are still around but wont be displayed in the list.
10
There is a distinction between restoring in paper space and restoring in model space and they are treated like the two different environments they are. This distinction was necessary to fix a legacy problem with restoring layer states in paper space. In earlier versions of the Layer State Manager, prior to AutoCAD 2008, if you had a layout with multiple viewports and you needed to restore a different layer state in each viewport, you ran a very high risk that every subsequent layer state restore, after the first one, would affect the look of the viewports restored before it. This happened because the model space on/off and freeze/thaw settings were automatically being restored while in paper space viewports. Since those settings are global visibility changes, you would have layers that were previously visible in viewport 1 being globally turned off by the restore to viewport 3. Very frustrating! Now, when restoring a layer state in a viewport, the Layer State Manager does not manipulate the model space on/off and freeze/thaw layer settings unless it is necessary to make a layer visible in the viewport. This avoids the problem encountered when restoring multiple layer states to multiple viewports.
11
12
All of these options can be set using the Layer Settings dialog, This dialog can be accessed through the Settings button in the Layer Properties Manager or by right-clicking on the layer notification icon on the status bar and choosing the New Layer Notification Settings context menu option. When first enabled, the default is to only notify you when new layers have been detected in attached xrefs however you can choose to be notified about all new layers. Layer notification does not occur during background publish operations (such as publishing from the Sheet Set Manager) even if the plot alert is enabled.
Additionally, all of these settings can be controlled using the LAYEREVALCTL, LAYEREVAL, and LAYERNOTIFY system variables. These system variables work together to control whether the layer list is evaluated and when notification occurs. The LAYEREVALCTL system variable is the master switch for layer notification on your system. It determines whether layer notification happens (LAYEREVALCTL = 1) or not (LAYEREVALCTL = 0). If you dont want layer notification happening in any drawing, ever ... set this to 0. The LAYEREVAL system variable controls whether or not new layer notification is enabled on a per-drawing basis and whether it evaluates all new layers (LAYEREVAL = 2) or only new layers in attached xrefs (LAYEREVAL = 1). LAYEREVAL is the master switch for new layer notification in each drawing. Setting it to 0 effectively turns off notification in that drawing. This setting is meaningless unless LAYEREVALCTL is enabled. The LAYERNOTIFY system variable is a bit-sum value that controls when an alert displays for new, unreconciled layers (see AutoCAD help for available options). All three of these system variables correspond exactly to the options in the Layer Settings dialog and allow you to control layer notification via the AutoCAD command line and automation tools such as AutoLISP and scripts. Changes to LAYEREVAL and LAYERNOTIFY are saved in the current drawing. Changing these system variables in one drawing does not change them in any other drawings nor does it change default behavior for new drawings. If you have specific values for these system variables that you want applied to all drawings, you should add them to your ACAD2010DOC.LSP file or your drawing templates (more on this later). How you setup layer notification will depend on how often you want AutoCAD to alert you to new layers and can be finetuned to acheive that ideal balance between time-saving safety and complete annoyance.
13
Using Templates
At this point you may be saying, Okay, this is cool but I use the same 200 layers in all my drawings! Do I have to reconcile them every time I start a new drawing? Not necessarily. If your drawing templates (.dwt) contain your standard sets of layers, you can reconcile the layers in each template. New drawings started from those templates will begin life with all layers reconciled and an established baseline. The best part is you dont have to manually reconcile the layers in your templates - all you have to do is re-save them. When saving a drawing as a template (.dwt) file, you are offered the Template Options dialog to provide additional information about the drawing template. This dialog includes options to save all the layers in the drawing as unreconciled or reconciled. By default, all layers are saved as unreconciled so that new drawings start without a baseline. If you choose to save the template file with all layers as reconciled, a layer baseline is automatically created. Now, new layers added to drawings started from that template are automatically unreconciled and new layer notification will kick in immediately. The template file is also a good place to make any changes you want to LAYEREVAL and LAYERNOTIFY (or the dialog equivalents in Layer Settings). For example, if you want your default behavior for new drawings to be that you are notified about all new layers but only when you plot, set LAYEREVAL to 2 and LAYERNOTIFY to 1 in the template and all new drawings will start with those settings.
14
15
Initially, the color, linetype, lineweight and plot style properties in these columns will be the same as the equivalent global properties. For example, both the Color and VP Color columns may show white as the current value. Changing these properties is exactly the same as changing the global properties: 1. Highlight the layers you want to change 2. Pick on the property to be changed 3. Choose a new property from the dialog The difference is that property changes made in these columns only apply to the current viewport. Another way to assign layer property overrides is by restoring saved layer states to a viewport. The Layer States Manager includes the Apply properties as viewport overrides restore option. Checking this option before restoring a layer state causes the layer properties being restored to be applied to the current viewport as layer property override values. This is an extremely quick way to set up the layer properties of a specific viewport with some confidence that those properties wont accidentally change because of work youre doing elsewhere in the drawing. This same functionality is also available through the VPLAYER command:
Enter an option [?/Color/Ltype/LWeight/PStyle/Freeze/Thaw/Reset/Newfrz/Vpvisdflt]:
The Color, Ltype, LWeight, PStyle options let you apply viewport-specific property overrides for specified layers (the PStyle keyword is only available from within a named plot style drawing). Property overrides assigned to xref layers are not retained when the VISRETAIN system variable is set to 0.
These layers are easily identifiable in the Layer Properties Manager when it is opened within a layout viewport. You can see which layers have overrides using any of the following: A background color displays for each layer name, override and corresponding global property setting. Hovering your cursor over the name of a layer with overrides will display a tooltip containing both the global and override property information for each property in that layer. The Status column will display a different icon for layers with property overrides. A group filter named Viewport Overrides will automatically be created in the tree view of the left pane. Selecting this will filter the layer list to only display those layers with viewport property overrides. The background color for the viewport overrides can be changed using the Layer Settings dialog.
16
Outside the Layer Properties Manager, various AutoCAD UI elements can also help identify layers with property overrides.
The layer combo box on both the Layers toolbar and the Layers panel of the Ribbon will display a background color behind layer names with property overrides in the current viewport (this is the same background color used inside the Layer Properties Manager). For color overrides, the override color is displayed in the combo box instead of the global color. The Properties toolbar will display ByLayer (VP) and a background color for layers or objects that are assigned property overrides. Override properties are displayed for color, linetype, and lineweight instead of global properties. You can also use the VPLAYEROVERRIDES system variable to check if the current viewport contains layer property overrides. This is a read-only system variable that returns 1 if the current viewport has associated layer property overrides and 2 if it does not. This is a quick way to check a viewport when no other visual indicators are available or when you need to check it programmatically.
17
The Layer Properties Manager has been around for a very long time and is well documented in the AutoCAD help. It is the central location for inspecting and managing layer visibilities and properties. Over the last couple of releases, this dialog has undergone some changes and I want to highlight a few commands and system variables you might not be aware of. By default, the LAYER command now displays the newer, modeless version of the Layer Properties Manager dialog. Modeless means that the dialog does not need to be dismissed when youre done with it and it can be left up and running (or automatically docked) while you do other things. Since this is not everyones cup of tea, it is still possible to access the older, modal style of the Layer Properties Manager dialog. The CLASSICLAYER command launches the modal version of the Layer Properties Manager dialog. As always, you must dismiss this dialog when youre done before you can do anything else. The LAYERPALETTE command runs the modeless version of the Layer Properties Manager dialog (shown above). By default, the LAYER command launches this version of the dialog, but you can change that to use the classic version using the LAYERDLGMODE system variable. When LAYERDLGMODE is set to 0, the LAYER command will run the original version of the Layer Properties Manager dialog (same as running the CLASSICLAYER command). When set to 1, the LAYER command runs the modeless version (same as running the LAYERPALETTE command). The LAYERCLOSE command, closes the modeless Layer Properties Manager dialog if it is currently open (this does not affect the classic layer dialog). The LAYERMANAGERSTATE system variable indicates whether the modeless Layer Properties Manager dialog is currently running. This can be useful if you need to programatically check for and close the dialog, e.g.,
(if (= 1 (getvar LAYERMANAGERSTATE)) (command ._LAYERCLOSE) )
18