LT On-line: Lesson 11

1 Feb, 2001 By: Mark Middlebrook

Xrefs: layers, loading, and logs
by Mark Middlebrook

Page 1: Xref layer visibility

My previous two LT Online lessons covered xrefs and how to attach and manage them with the Xref Manager dialog box. This lesson rounds out xref coverage with a trio of topics: how to control xref layer settings with the VISRETAIN system variable, when to use demand loading, and how to troubleshoot xref problems with text window messages and the log file.

The procedures described here work with AutoCAD LT 98 and 2000 and AutoCAD Release 14 and 2000.

Xref layer visibility
As described in the "Layer-palooza"

Click for larger image
Click for larger image
Figure 1.
section of lesson 9, when you attach one file to another as an xref, AutoCAD adds new layers to the parent drawing that correspond to the layers in the xrefed DWG. The xrefed layers have the form Xrefname|Layername, as shown in figure 1. You might wonder what happens when you make changes (on/off thaw/freeze, color, linetype, etc.) to these xref layers or to the corresponding layers in the xref itself.

In particular:
• If you change the settings of an xref layer in the parent drawing, do the changes persist after you close and reopen the parent drawing?

• If you change the settings of a layer in the child drawing, do the changes appear the next time you open the parent drawing?

The answer to both of these questions depends on the setting of the VISRETAIN system variable in the parent drawing. VISRETAIN is short for visibility retain, and this system variable determines whether layer settings in the parent drawing or the child drawing control the appearance of xref layers in the parent.

The default VISRETAIN setting is 1 (= on), which means that the parent drawing's settings for xref layers control over the settings for the corresponding layers in the xref drawing itself. For example, assume that you have attached MYSCREW.DWG (the child drawing into MYWIDGET.DWG (the parent drawing). If you turn off the xref layer Myscrew|Text in the parent drawing MYWIDGET.DWG, that layer will still be off the next time that you open MYWIDGET.DWG. Furthermore, if you later open MYSCREW.DWG and change its Text layer from red to green, the Myscrew|Text layer ignores this change. The Myscrew|Text will still be red when you open MYWIDGET.DWG.

If you change VISRETAIN to 0 (= off) in a parent drawing, you tell AutoCAD that the child drawing's layer settings control over the parent drawing's settings for the corresponding layers. Each time you open the parent drawing, AutoCAD applies the current layer settings from the child drawing. For example, if you turn off the xref layer Myscrew|Text in the parent drawing MYWIDGET.DWG, it goes off for the current session. The next time that you open MYWIDGET.DWG, though, the Myscrew|Text layer is back on, because that's its current setting in MYSCREW.DWG. Furthermore, if you later open MYSCREW.DWG and change its Text layer from red to green, the Myscrew|Text layer reflects this change when you open MYWIDGET.DWG (i.e., the layer Myscrew|Text layer is green).

Note that all of this VISRETAIN discussion applies only to how the layers appear in the parent drawing. No matter what you set VISRETAIN to in any drawing, the child drawing's layers don't change when you change xref layer settings in a parent drawing. In other words, changes to the Myscrew|Text layer in MYWIDGET.DWG don't affect the Text layer in MYSCREW.DWG, regardless of what VISRETAIN is set to.

There are ferocious arguments about whether to turn VISRETAIN on or off. I prefer when possible to turn off VISRETAIN and thereby control the visibility and properties of xrefed layers from the child drawings. But you may want to or need to set VISRETAIN to 1 and control xref layer visibility and properties from the parent drawings (in order to be able to assign different properties to the same layer in different parent drawings, for example).

The most important thing is that you choose one method and stick with it. If you aren't consistent, you can't predict whether changing a layer in a parent or child drawing will persist.

In order to change the VISRETAIN setting in AutoCAD or LT 2000, open the Options dialog box (Tools|Options), and choose the Open and Save tab, as shown in the figure below. Click the Retain Changes to Xref Layers check box to turn VISRETAIN off or on. In LT 98 or AutoCAD Release 14, you must type the system variable name at the Command line. Type VISRETAIN,

Click for larger image
Click for larger image
Figure 2.
press ENTER, type 0 (off) or 1 (on), and press Enter again. Whether you change the system variable from the Command line or the Options dialog box, you're changing it only in the current drawing file. The setting is stored in the DWG file, so that different drawings can have different VISRETAIN settings shown in figure 2.

If all of these abstract file and layer names have your head spinning, the best thing to do is to test both settings:

1. Create a sample parent and child drawings (e.g., PARENT.DWG and CHILD.DWG). Draw some objects on different layers in CHILD.DWG.
2. Open PARENT.DWG and xref attach CHILD.DWG into PARENT.DWG.
3. Set VISRETAIN to 0.
4. Use the Layer Properties Manager dialog box to change settings for some of the xref layers in PARENT.DWG.
5. Save and reopen PARENT.DWG. Note that the layer changes have disappeared.
6. Open Child drawing, make some changes to the layer settings, and save the drawing.
7. Reopen PARENT.DWG. Note that the layer changes from CHILD.DWG appear in PARENT.DWG.
8. Repeat steps 3 through 7, but set VISRETAIN to 1 instead. Note that in step 5 the layer changes now persist and in step 7 the layer changes from CHILD.DWG do not appear inPARENT.DWG.

A tutorial on my Web site demonstrates these concepts.

Xrefs: layers, loading, and logs
  Page 1: Xref layer visibility
  Page 2: Demand loading
  Page 3: Xref messages and the xref log file

About the Author: Mark Middlebrook

AutoCAD Tips!

Lynn Allen

In her easy-to-follow, friendly style, long-time Cadalyst contributing editor Lynn Allen guides you through a new feature or time-saving trick in every episode of her popular AutoCAD Video Tips. Subscribe to the free Cadalyst Video Picks newsletter, and we'll notify you every time a new video tip is published. All exclusively from Cadalyst!

Follow Lynn on TwitterFollow Lynn on Twitter

Do you use any augmented or virtual reality (AR or VR) technologies in your workflow?
Not yet, but we are planning to implement it.
No, but we think these technologies could hold value for us.
No; these technologies do not hold value for us.
Submit Vote

Download Cadalyst Magazine Special Edition