AutoCAD

X Marks the Ref (Learning Curve AutoCAD Tutorial)

1 Oct, 2008 By: Bill Fane

Behold the power and capabilities of externally referenced files in AutoCAD.


It was a dark and stormy night. It had rained more than two inches in a few hours, breaking a record set in 1909. The problem was that it was mid-August. There would be no water skiing in the morning, because by then the lake level would have risen by more than a foot. Another problem was that the mooring lines on the ski boat did not have much slack in them, and so the boat was being held down about four inches lower in the water by mooring lines that were too taught to undo.

Meanwhile Captain LearnCurve and his gorgeous wife were watching an old rerun of The X-Files on TV. The first few years of this series had been filmed in the Captain's home town of Vancouver, and it was fun identifying the real locations that they were passing off as Florida or Utah or who knows where.

That's it! This month's topic! X-Files!

X-files?

You'll see what I mean in a minute.

I assume you already know about how to create and insert blocks in AutoCAD, but I'll start with a bit of a review anyway so you can see how xrefs fit into the great cosmic scheme of things.

Using the BLOCK command, you can link a collection of objects together to make one big super object out of them. This BLOCK of objects can then be INSERTed repeatedly within your drawing. This is far more efficient than COPYing the individual objects, because the drawing contains only one definition of the block. Each insertion only adds a few hundred bytes to the drawing file to point back to the same block definition, regardless of the size of the block.

A further advantage of blocks over copying is that if you change the definition of the block, then all insertions of it update automatically.

You can also insert a block that has not previously been defined within the drawing. AutoCAD can inhale any existing drawing file from a disk and add it as a block definition within the current drawing. This allows you to build a library of standard details, title blocks, company logos, and so on as separate drawing files that can be inserted as desired into any drawing.

Unfortunately, this latter technique has two minor flaws:

  1. Each and every drawing file that contains a block inserted from a disk grows by the size of the inserted drawing. If you have 1,000 drawings that each contains a copy of a 100k company logo file, then your disk drive contains 100 of the same logo, over and over again. Yes, I know disk drives are available up in the terabyte range, but it is still clutter.

  2. If you change the original library drawing you have to remember to update its definition in any other drawing that contains it as a block.

The good news is that there is a simple alternative that overcomes this problem, and that is the use of the Xref command.

As indicated earlier, xref means "eXternal REFerence". An xref works almost exactly like a block with one significant difference, being that the block definition is not contained within the current drawing. The portion of the drawing that normally contains the block definition data does not actually contain the data but instead it simply contains the name of another drawing file on disk.

I see. And that is why you referred to that eXternally-REFerenced file as an X-file?"

No, I would never do that because this is a high-quality column.

...and if that file were named TRUTH would you say the TRUTH is out there?

Now cut that out!

Once an xref is defined, AutoCAD goes out to the disk and gets the block definition from the other file every time the parent drawing is opened for editing. Xrefs neatly overcome both of the problems outlined above:

First, each drawing that contains xrefs increases in size only by a few hundred per xref definition. Our 1,000 drawings would thus require only about one or two MB in total to point to the single 100k logo file.

Conversely, an assembly drawing that xrefed 20 component parts might appear as only a 200k file in a folder listing, but could easily xref another 10 or 30 MB of related drawings.

Second, the xref is read in automatically each time the host drawing is opened for editing, so by definition the host will always show the latest definition of the block.

Before getting into the mechanics of xrefs, let me outline some of the potential uses:

  • As previously indicated, they can be used for title blocks and logos. We had more than 2,500 drawings when the company changed ownership and a new corporate logo came along. We only had to change one drawing because all the others automatically showed the new logo whenever they were opened.

  • An assembly drawing can be built by xrefing the component parts, and the assembly drawing will always show the latest version of the parts.

  • Many "master" drawings can all point to the same xref. This can be particularly useful when a number of drawings need access to the same "background" data. In architectural applications, for example, there can be different drawings for structural, electrical, plumbing, ventilation, and so on, but they can all xref the same wall plan. Any change to the wall plan drawing will be reflected to all related drawings. This works particularly well in a network setting.

Let's start with a simple example, and then I'll come back and fill in some details. I'll also hit you with the lumpy bits.

As usual, there are several ways of invoking the Xref command. Now here is one way that you can detect a long-time AutoCAD user, because the command is not xref any more. The current command is ExternalREFerences, but xref is an alias for it to ensure compatability with customizing and with old users.

Anyway, you can type in either command at the Command: prompt, or you can select Insert | External References from the menu bar, or you can pick the External Reference button from the Reference toolbar, or you can pick the External Reference button from the Blocks & References tab of AutoCAD 2009's ribbon menu.

In any case, AutoCAD brings up the External Reference tool palette, seen here:

figure
The External References tool palette is used to manage external references.

Note that I referred to it as a palette. This means that it can remain active on screen while you continue with other work, and it can be set to auto-hide until you roll your cursor over it, and it can be given transparency. Yours may not look exactly like this because I stretched some of the column widths in order to show you their full header names or their content.

Initially it contains one reference, being the current drawing itself. This may seem a little odd, but there it is.

Click on the Attach DWG button in the upper left corner. From now on the operation of this command is pretty much intuitive. It starts with a standard file selection dialog box. Browse to and select the desired file.

When you do, AutoCAD then brings up a dialog box that looks very much like the standard block insertion one. The only differences are that it is titled External Reference, you can't select or browse to any other block definition, and there is a region in the middle with options concerning reference type and path type. We'll come back to the last two items later, but for now leave them at their default settings of Attachment and Full Path.

Other than that, you can perform all the usual block insertion operations such as selecting the insertion point, the X, Y, and Z scale factors, and the rotation angle.

That's it! You have now created your first external reference. Pretty simple, wasn't it?

The Good News

  1. An xref behaves almost exactly like a standard block insertion. You can modify its location, rotation angle, and scale factors. You can copy, array, and erase it. You can use object snaps to locations within it. You can freeze, thaw, and change the properties of the layers within it in the current drawing without changing the original file back on the disk.

  2. They can be inserted into model space or into paper space layouts.

  3. An xrefed file can itself contain other xrefs, just like normal block definitions. Unlike normal blocks, however, it can be made possible for an xref to include circular references. For example, block A can contain B which contains C, but C cannot contain A. This can be made to work in xrefs, however.

Okay, now the lumpy bits.

  1. If you move or rename the attached xref file, then the link from any host drawings that reference it get broken, and will need to be repaired. We'll cover this next month.

  2. If you send a copy of the host file to someone, then you must also remember to send any and all xref files.

  3. AutoCAD creates duplicates of all named objects in the xref, including layers, text styles, dimension styles, and so on, even if identical ones exist in the host. The only exceptions are layers 0 (zero) and DefPoints.

The new names for these objects have the format <file name> | <object name>. You should probably Purge a file of all unused named objects before you attach it. Even then, architectural drawings in particular can get pretty wild. These drawings often have dozens, even hundreds, of layers. Now attach a dozen xrefs to a single host and it can end up with several thousand layers.

This has been a brief introduction to externally referenced files. Be sure to come back next month when we explore such fascinating capabilities as clipping, binding, unloading, and reloading of xrefs.

And Now For Something Completely Different
I have finally figured out airline ticket pricing. They use a random number generator. There can be no other explanation as to why a ticket for a flight three months out will be a given price one day, 30% cheaper the next day, then higher than the initial price on the third day.


AutoCAD Tips!

Lynn Allen

Autodesk Technical Evangelist Lynn Allen guides you through a different AutoCAD feature in every edition of her popular "Circles and Lines" tutorial series. For even more AutoCAD how-to, check out Lynn's quick tips in the Cadalyst Video Gallery. Subscribe to Cadalyst's free Tips & Tools Weekly e-newsletter and we'll notify you every time a new video tip is published. All exclusively from Cadalyst!
Follow Lynn on Twitter Follow Lynn on Twitter



Poll
Which file format do you use most often for CAD drawing/model exchange?
Native format
PDF
3D PDF
DWF
STEP or IGES
JT
IFC
Other
Submit Vote