A Stroll down the Xref Path (Learning Curve AutoCAD Tutorial)

30 Nov, 2008 By: Bill Fane

The third and final installment in the saga of the mighty xref.

It was a warm and sunny afternoon. Captain LearnCurve and his gorgeous wife were on yet another special assignment, as their driver adroitly maneuvered his taxi through the traffic of beautiful downtown Barcelona.

Barcelona! You certainly do get around, don't you?

Yes. It seems that if you do a bit of writing, the software companies think you are a journalist, and they invite you on junkets to all sorts of different locations to celebrate the next release of their software. This time it was SolidWorks 2009.

That's it! This month's topic! Different locations!

In my October and November columns I discussed how to link other drawings into a host drawing using the ExternalREFerence (Xref) command, and how to clip them so that only selected portions of them are visible in the host.

This time we will turn on the Wayback machine, and go way back to the first of the two columns. At the time we simply inserted the Xref using the default values, but it is now time to go back and look at some of the options.

Where Does This Path Go?
Start a new drawing, or open an existing one, and attach a new external reference. As usual with AutoCAD, there are a number of ways of doing this. The basic command is ExternalREFerences, but the xref shortcut is much easier to type in. We can also cheat a bit and enter XAttach, which jumps straight to the Attach option of the basic command. On the other hand, we can also use the appropriate toolbar button, menu pick, or ribbon panel item.

Select a suitable file. Next, AutoCAD displays the External Reference dialog box. As we saw in Episode one, this is almost exactly like the normal Insert dialog box that appears when we are inserting a block.

Almost is the operative word here. Observe the Path Type window in the figure. It is highlighted in blue, and says Full Path. This is the default. Let's review it, followed by the other two options available in the dropdown list.

Full path: The host drawing remembers the exact, full path to the inserted file, from the drive letter on down to the name of the file, as indicated in the upper portion of the dialog box in the figure. This can also point to a network server or it can be a URL to a website.

Full Path is usually the safest because it stores the full path for each file. Whenever the host is opened, it will automatically find the correct xref. On the other hand, if any xref is moved to a different folder, the host won't be able to find it.

Relative path: The host drawing remembers the name of the inserted file, plus its path relative to the host drawing. This works best if the location of the inserted drawing is a subfolder of the one holding the host drawing. The entire folder structure can be moved to a different drive or different main folder without any problems.

If the inserted drawing is located in a folder that is not a subfolder of the one housing the host drawing, things can get messy if things change.

This option is not available if the inserted drawing is located on a hard drive different from the host drawing, be it another local drive or a network drive.

No path: The host drawing remembers just the name of the inserted file. Under certain conditions, the host may load the wrong xref.

An important point to note here is that the path type is set individually for each xref, so that a single host drawing can contain xrefs with all three types of path.

What Can Possibly Go Wrong, Go Wrong…
As indicated in a previous article, one of the weaknesses of xrefs is that problems can arise if you send a host file to a different user, or if you move it or any of its related xrefs to a different drive or folder, or if you rename an inserted file.

Let's start with the easy one. If you want to send a host drawing to someone else, you have to be sure you also send all of its attached xrefs. What is often overlooked is the fact that an inserted xref can in turn contain more xrefs and so on, to several levels deep. When a host drawing is sent to someone else, the nested xrefs can get missed.

There are two solutions to this problem. One is to start the ExternalREFerences (or xref) command and then manually note every xref file name so they can be included in the package. The two buttons at the right-hand end of the File References bar let you switch between a flat list or a tree view.

The easy solution is to use the E-transmit command. It neatly bundles the host drawing and all attached xref files into a convenient single zip file. To learn more about this, see the link to my column of … wait a minute! I haven't done one on E-transmit yet! Hmmm. That sounds like a good topic for next month.

Now let's look at the implications if things have changed and the host can't find an xref. When the host is opened, it first looks for each xref in the original path location. Note the implications of the different options of the Path Type specification.

If the host can't find the xref, it looks in the current folder of the host drawing.

Next, it looks in the folders specified in the ProjectName system variable. So, you have never heard of AutoCAD projects? No problem. Project functionality was created specifically to make it easier to control unruly xref search paths. Check out the July 2008 Learning Curve.

If the host still can't find the xref, it then looks in the folder search path specified under the Files tab of the Options command.

Finally, in desperation, it looks in the Start In folder specified in the properties of the desktop icon that was used to launch AutoCAD.

Now you can see why the No Path option in particular can cause the host to load the wrong xref. If the file name matches, it uses it.

If the host still can't find the file, it displays an error message, and replaces the xref in the drawing screen with a rectangle containing the xref name.

What's in a Name?
We now come to two possible issues with xrefs versus layer names.

First, when an xref is inserted into a host, AutoCAD creates a new layer in the host for each layer in the xref, even if it is the same as a layer already in the host. To differentiate them, it adds the xref file name and a vertical separator bar to the front of the layer name. Architectural drawings in particular can get interesting, because they often have dozens or even hundreds of layers. Now xref a dozen of these into a host and you can get thousands of layers, especially if there are nested xrefs involved.

The second issue is related to the first. The maximum length for a layer name is 255 characters. This limit can be reached if a very long file name contains very long layer names, but it is not usually a problem. It was worse in the earliest releases when the xref layer name included the full path to the xref, and the maximum name length was only 31 characters.

By the way, this also applies to other named definitions including text and dimension styles, line types, and block definitions.

Here's Looking at You
The properties of an xref layer, such as color and line type, can be modified in the host drawing. This does not affect the source file, so several hosts that reference the same xref can have different layer properties in each host.

By default, such property overrides are not saved, and so everything reverts to the xref's specifications when you close the host drawing file.

If you want to retain the xref layer overrides between sessions, simply change the VISRETAIN system variable from the default value of 0 (zero) to 1 (one). There is no menu or toolbar pick for this, so you need to enter it at the Command: prompt.

Now Here's a Fine Bind You've Gotten Us Into
Start the ExternalREFerences command again in a drawing that has one or more xrefs attached to it, and then right-click on one of the xref names in the External References palette. This brings up a context menu with six choices:

  • Open: Opens the selected xref so you can edit it.
  • Attach: Lets you place another insertion of the selected xref, or you can browse to a different file and attach it.
  • Unload: The selected xref is unloaded from memory. This is useful if you have a large host with many attached xrefs, but only need to work on a small portion of the host. You can unload the unneeded files, thus freeing up memory and speeding things up. The host drawing still remembers the link, and it remembers the loaded/unloaded state if you close the drawing.
  • Reload: Obviously reloads the selected xref back into the host. It can also be used to update a loaded xref, which can be needed if you have a host open and someone else in a network environment has changed the xref file.
  • Detach: Be careful with this one. It detaches the xref, which means it breaks the link to it. So far so good, but it also deletes all current insertions of it without the usual "Are You Sure?" prompt.
  • Bind: This option converts the xref file into a standard block definition within the host and then breaks the link to it. This can be useful when sending a host file to someone else, as long as you realize that changes to the external files will no longer update the host. You may want to make a copy of the host and bind it for sending, keeping your original host intact.

Overlay One on Me
There is one final option available when inserting an xref. Consider this scenario. Drawing A contains an xref to B, which in turn contains an xref to C. So far so good, except that you are now editing C and need to refer to geometry located on A.

If you attempt to attach A, you will end up with a circular reference: A > B > C > A > B > C…

Fortunately there is a solution. As you attach A to C, simply select the Attachment radio button in the External Reference insertion dialog box. AutoCAD will warn of the circular reference and invite you to quit or to proceed. If you proceed, it will now just load A into C, without loading B and hence it won't load C again.

As we have seen in these three columns, external references are a useful, powerful tool.

And Now for Something Completely Different
If you wear glasses, you should carry a tube of instant glue with you in case you are driving at 70 mph on a Spanish freeway and your frames break, allowing one lens to pop out.

More News and Resources from Cadalyst Partners

For Mold Designers! Cadalyst has an area of our site focused on technologies and resources specific to the mold design professional. Sponsored by Siemens NX.  Visit the Equipped Mold Designer here!

For Architects! Cadalyst has an area of our site focused on technologies and resources specific to the building design professional. Sponsored by HP.  Visit the Equipped Architect here!