Learning Curve: 3 Times Tables13 Feb, 2006 By: Bill Fane Cadalyst
Captain LearnCurve dives even deeper into table functionality to discuss styles, blocks and equations.
It was a warm and mild evening. In fact, it had set a record high temperature for the date. This was the bad news, considering that it was the middle of ski season. The good news was that it gave Captain LearnCurve time to work on his next column.
My last two columns discussed the Table functionality introduced in AutoCAD 2005. You learned how to create them and how to edit them. If you think tables are interesting so far, then hang onto your hat because the fun has just begun.
That's a Stylish Name
As you saw in the previous two articles, you have a great deal of control over the format and appearance of tables. For example, you would set up a bill of material differently from a revision history table, which you'll set up differently again from a symbol legend table, etc. What if you want the same two or more different styles in one drawing? Do you have to create each style each time? Of course not.
Let's get into the 'Wayback Machine' and go 'way back to the first figure of the first article in this series. It shows the dialog box that appears when you create a new table (Draw / Table). In the upper left corner, note the Table Style Name window and the fact that it says Standard. Note also that it says the text height is 0.1800, but it doesn't look like you can change this value. Obviously the cell sizes are based on the text size, but you might need a larger size. A size of 0.125 is probably more reasonable for Imperial drawings, while metric drawings would usually use 2.5 mm.
No problem. Click on the button to the left of the text size, and AutoCAD brings up the Table Style dialog box. It's not worth showing an illustration of it, because its action is pretty obvious. You can use it to create a new style or to modify an existing one. Click on the Modify button to edit the existing Standard style (figure 1).
Figure 1. The Modify Table Style dialog box.
A quick inspection of this dialog box reveals that you can completely define the format of a table using this dialog box. In particular, note the text height window. This value only applies if the selected text style has a height of zero, otherwise the height specified in the text style definition (Format / Text Style) applies.
The functionality of each of the three tabs is identical, but they each apply only to their designated portion of the table.
Knowing what you know now, all you need to do is define the desired styles within a drawing and save the drawing as a template file. When you create a new table within a drawing started from this template, you can simply select the desired style from the scroll list in the upper right corner of the Insert Table dialog box.
Now let's move on to look at some of the other functionality in tables.
A Word Is Worth .001 of a Picture
You are not restricted to putting simple text into a table cell. If you want to, you can also insert a block. The basic procedure is extremely simple, but it does have a couple of restrictions.
First, the simple part. Create a table or open a drawing that contains an existing one. Next, click within the desired cell to make it active, then right-click anywhere in the drawing to bring up the table-editing context menu (figure 2).
Figure 2. The table-editing context menu of AutoCAD 2005.
Now click on Insert Block to bring up a dialog box (figure 3).
Figure 3. The dialog box used to insert a block into a table cell.
The operation of this dialog box is pretty obvious. The top portion lets you select from a scroll list of any block definitions held within the current drawing, while the Browse button opens a standard file dialog box so you can browse for any existing drawing file on disk.
Likewise, the operation of the Properties portion is largely self-evident, although AutoFit is worthy of additional comments. As its name implies, the block insertion will automatically scale so it fits within the target cell. The cunning bit is that it will resize itself later if the cell size is changed.
We now come to several restrictions, rules and general comments.
First, a block insertion into a cell table only ever shows the plan view of the WCS (world coordinate system) of the extents of the block in model space. Paper space layouts, and objects within them, are ignored as are named views and 3D viewpoints. You cannot freeze or thaw layers independently of the rest of the drawing.
Next, a block inserted from disk becomes a new block definition within the host drawing. You cannot make it an xref, so it will not update automatically if you insert drawing changes.
Finally, a block insertion into a cell becomes part of the table object. This means that objects within the block definition that were created on layer 0 (zero) take on the line type, line weight and color properties of the layer on which the table lives. Objects within the definition created on other layers or with color, line type or line weight overrides retain their specified appearance.
This capability extends the usefulness of tables beyond parts lists or revision history listings. For example, how about a legend table that displays a sample of all the symbols used in a drawing along with the name and description of each symbol?
A cell can contain text or it can contain a block, but it cannot contain both at the same time. The good news is that you can cheat a little bit. Simply put the block in one cell, the text in an adjacent one, and then edit the cell borders to make the common wall invisible.
Okay, there is a bit of a trick to making the cell wall invisible. First, select the two cells, then right-click and select Cell Borders when the context menu appears (figure 4).
Figure 4. The Cell Border properties dialog box.
The secret to success is that you have to start from nothing before you can have anything. Go to the Apply To section and click on the No Borders button in the upper right corner, and then click the Outside Borders button. Click OK. The suppressed border line still displays a ghost image but does not plot.
Fields of Dreams
Table text cells can also contain fields, by themselves or within other text. A field is a special type of text object that automatically updates itself when things change. For example, a field can automatically show the date when the drawing was last plotted, or the area surrounded by a polyline. How would you like a room schedule whose areas update automatically when the floor plan changes? I thought so.
So far, everything in this series of articles has applied to AutoCAD 2005.
AutoCAD 2006 made only one addition to table functionality, but it is a good one. Cells can now contain formula references to other cells, much like Microsoft Excel spreadsheets. A column might contain fields that show the areas of a series of rooms, for example, plus a cell that shows the sum total area of the building.
Remember a little earlier when you inserted a block into a table cell? You clicked within the cell, and then right-clicked to bring up the context menu. Well, in AutoCAD 2006 you get a slightly different context menu (figure 5).
Figure 5. The AutoCAD 2006 table-editing context menu.
If you click one of the first three items, the menu will disappear and you will select a range of cells. You can click in any two cells and AutoCAD will sum, average or count the number of numeric entries within the range and place the result in the original target cell.
I'll mention a couple of points to note about this process.
First, you don't need to confine the range to a single row or column. It can apply to a rectangular block of multiple rows and columns, and the formula will apply to all cells within the range.
Obviously, you can't include the target cell within the range.
Next, the function only applies to cells that contain numeric values. If a range contains a mix of numbers and words then the program will add, average or count only the numbers.
Finally, the function is reactive. If you later change a value within a cell, then the resultant in the target cell will update instantly.
Okay, I lied. That's a couple of couple of points.
The Cell menu pick is an interesting one. It invites us to select a cell, and then its value is reflected to the target cell. Once again, this function only applies to numeric values. If the indicated cell contains text, then it simply returns #####.
The interesting thing here is that you can point to any cell in any table almost anywhere in the drawing. The only requirement is that you cannot link between a paper space layout and model space, nor can you link between two different layouts.
The really interesting thing here is that the same rules apply to the other functions as well. For example, you can display a value in a cell of one table that is the sum of the values of a range of cells in a different table.
The really, really interesting function is the Equation menu pick. When you select it, the standard Text Formatting tool appears along with the column and row indicator bars (figure 6).
Figure 6. Entering an equation into a table cell.
There are two salient points to observe in this figure.
First, I am just using the generic table cell text entry and formatting tool. Cell D7 shows a typical equation.
Second, the row number and column letter indicators have appeared, so I can identify cells.
A few simple rules apply to the syntax of an equation, which are almost identical to those for Microsoft Excel:
- Equations must start with an = (equal) sign.
- A single cell is identified by its column letter then row number; for example, D7.
- A range of cells is indicated by two cell identifiers separated by a colon; for example, C3:F7.
- A comma can be used to add additional cells to the range; for example, C3:F7,D4:H9,A4 builds a range consisting of two sub-ranges and a single cell.
- If an equation is copied to another cell, then the cell identifiers within the cell offset themselves accordingly. To maintain an absolute location, the equation always points to the same place when an equation is copied, precede the column letter and/or row number with a $ sign. For example, a constant Imperial-to-metric conversion factor might be stored in $G$2.
- Equations can include the following operators: Sum, Average, Count, + (plus), - (minus), * (multiply), / (divide) and ^ (exponent).
- Parentheses ( ) can create nested expressions.
A bit of experimentation will also reveal that the Sum, Average and Count menu picks are simply macros that supply the appropriate values to an equation. They can also be typed in directly.
Now that you understand the rules, you can see that cell D7 in Figure 6 takes the quantity of each item in turn, multiplies it by the unit weight and adds them all up to produce a grand total. In the example, the total is 17.7 lb.
If any weights or quantities change, then the total will update.
AutoCAD's table functionality is a powerful ally in our fight for productivity and accuracy. As you have seen, they are extremely easy to set up and use and yet they are very versatile.
And the good news is that it has started snowing heavily on Whistler. Check out the their web site.
And Now for Something Completely Different
If you have medications that must be taken every day, and if you are traveling, especially to another country, then you should pack your trip's requirements in your suitcase and carry a duplicate quantity with you. This way, if one set gets lost, then you will still have enough to get you home.