New Commands in AutoCAD 2005: Part 5
Text That Updates Automatically
by Ralph Grabowski
Introduction
This month, we look at commands that create an entirely new kind of
text -- new to AutoCAD 2005, that is. These commands and system variables
create and edit text that updates automatically: Field, UpdateField,
FieldEval, and FieldDisplay.
What is field text? It is text that consists of a variable, and displays
the variable. It's kind of like attributes, but with two differences:
they don't need to be part of a block, and you don't provide their values
-- AutoCAD does. Field text can part of mtext, attributes, and in tables.
To distinguish field text from "normal" text, AutoCAD places
a gray rectangle behind the text.
You can, for example, use the Field command to place in the corner
of the drawing the date and time the drawing was last saved; these are
updated each time the drawing is saved. You can insert the following
kinds of data as field text:
* Dates and times of creation, saving, and plotting.
* Information about the document, such as author and filename.
* Hyperlinks
* Any object in the drawing and its properties.
* Any system variable.
* Plot parameters, such as paper size, scale, and orientation.
* Diesel expressions (simple macros).
* Data about sheet sets.
AutoCAD 2005 adds these commands for creating and controlling fields:
Field - inserts field text in the drawing.
UpdateField - forces the values of fields to update.
FieldEval -
FieldDisplay - toggles the display of the gray rectangle
behind field text.
TIP: In addition to placing field text directly in
drawings, you can use the MText command's Insert
Field option and the AttDef command's Field
button to place fields within mtext and attributes. The Find
command searches (and optionally replaces) field text
Finding the Commands
Field Command
To start the Field command:
• From the Insert menu, select Field.
• At the command prompt, enter the field command.
In all cases, AutoCAD displays a dialog box listing the field text you
can choose from.
UpdateField Command
To start the Updatefield command:
• From the Tools menu, select Update
Fields.
FieldEval System Variable
To access the FieldEval system variable:
• At the command prompt, enter fieldeval as a
command.
FieldDisplay System Variable
To access the FieldDisplay system variable:
• At the command prompt, enter fieldisplay as
a command.
Step-by-Step Tutorials
Placing Fields
To place field text in drawings, follow these steps:
1. With AutoCAD 2005, start a new drawing, or open an existing drawing.
2. Start the Field command. Notice the dialog box;
its content changes, depending on the type of field text you select.
In many cases, the dialog box consists of three primary areas: you select
a category (A), a sub-category (B), and a formatting style (C).
Figure 1: Insert Field dialog box.
3. For this tutorial, select "Date & Time" from the
Field Category list. Notice that this shortens the list under
Field Names, making it easier to find a specific field name.
4. From the Field Names list, select "Date."
Notice that the center column has two lists:
Date format -- allows you to enter a date code, such
as MMMM d, yyyy. The Hints column (at the right) gives you the meaning
of many, but not all, date codes.
Examples -- allows you to chose a preset example date
and time format.
5. Select any date and time format from the Examples
list, and then click OK.
6. At the command line, AutoCAD prompts you to place the field text:
MTEXT Current text style: "Standard"
Text height: 0.2000
Specify start point or [Height/Justify]: (Pick a point.)
The current date (and/or time) appears in the drawing, with a gray
background.
Figure 2: Field text placed in the drawing.
TIPS: Sometimes the field displays four dashes (
---- ). This means the field does not yet have a value. For example,
the Filename field does not show a value until the drawing is saved
for the first time.
In other cases, fields display four hash marks ( #### ). This means
the field value is invalid. For example, the CurrentSheetNumber field
is invalid when the drawing is in model space.
Updating Field Text
Field text can be updated in two ways: manually or automatically. The
UpdateField command forces the value of selected fields
to be updated manually. The FieldEval system variable
determines when fields are updated automatically.
To force selected fields to update, follow these steps:
1. With AutoCAD 2005, start a new drawing. Draw a circle.
2. Start the Field command, and then select "Objects" from
the Field Category list.
3. Under Field Names, select "Object."
4. Click the Select Object button (next to the Object
Type text box).
5. The dialog box disappears, and AutoCAD prompts you at the command
line:
Select object: (Pick the circle.)
6. Select the circle, and the dialog box reappears. Notice that the
Property list contains all the properties of the circle
known to AutoCAD.
7. From the Property list, select "Area."
Figure 3: The Field dialog box changes to suit the type of field text.
8. From the Format list, select "Engineering."
Notice that the dialog box reports the area of the circle in the Area
box (upper right).
9. Click OK. At the command line, AutoCAD prompts you
to place the field text:
MTEXT Current text style: "Standard" Text height: 0.2000
Specify start point or [Height/Justify]: (Pick a point.)
The area of the circle appears in the drawing, with the gray background.
Figure 4: The area of the circle displayed as field text.
10. Change the size of the circle: select the circle; click on a blue-colored
grip, turning it red; drag the red grip, changing the size of the circle.
Press Esc to un-select the circle. Notice that the
field text does not change; you need to force the change, as described
next.
Figure 5: Changing the size of the circle through grips editing.
TIP: Field text does not attach itself to objects;
like text and mtext, it stays where you place it. In this case, the
area-of-circle field text does not attach itself to the circle; if you
were to move the circle, the field text stays behind. The exceptions
are, of course, field text in attributes and table cells.
11. Enter the UpdateField command, and then select
the field text.
Command: updatefield
Select objects: (Select the field text.)
1 found Select objects: (Press Enter.)
1 field(s) found 1 field(s) updated
12. Press Enter, and the field text updates to reflect
the larger circle area.
Figure 6: Updating the value of the field text.
13. The gray background alerts you and others that the text is special;
if you don't want to see the gray rectangle, change the value of the
FieldDisplay system variable to 0 (zero):
Command: fielddisplay
Enter new value for FIELDDISPLAY <1>: 0
Regenerating model.
The gray disappears.
Figure 7: Hiding the gray background to field text.
|