Rtext automatically updates drawing text1 Dec, 2000 By: Bill Fane
Captain LearnCurve heard the plaintive cry of a far-off AutoCAD user: Woe is me! I have to put the same legal disclaimer text in 20 different AutoCAD drawings! Just create it in one drawing, then cut and paste it into the others. You don't understand! The lawyers haven't finalized the wording yet, but I have to get preliminary drawings out right away. I'll need to change them all later. No problem. Use the Rtext command. Say what? My copy of AutoCAD doesn't have that command! Rtext is one of AutoCAD's Express Tools. The box below explains the whats and wherefores of the Express Tools in various versions of AutoCAD. Once you load the tools, we'll take a look at the Remote Text Express Tool.
Rtext is much like AutoCAD's Xref command, except that it works with text files. The basic operation is simplicity itself. In fact, it is easier to demonstrate with an example than it is to explain.
|Figure 1. Use Notepad to create a simple text file.|
Start up Notepad and enter a bit of text, as shown in figure 1. Save it to a suitable directory and filename. Now start AutoCAD. Open an existing drawing or start a new one.
Invoke the Rtext command from the Command prompt, or pick Express Tools|Remote Text from the menu bar. Sorry, there's no toolbar pick for the textually challenged.
When Rtext starts, ignore the prompt for the time being and just press <Enter>. Up pops a standard file selection dialog box. Select the text file that you just saved. The text in the file appears as a ghost image, and you can use the cursor to drag around a rectangle the same size as the text. Drag the rectangle where you want to position the text, pick a point, then press <Enter> to take the remaining defaults.
|Figure 2. Rtext then creates a special object based on the text file.|
Magic! The text from the Notepad file appears as an AutoCAD object in your drawing. It's located on the current layer and takes that layer's color.
If you think that was good, try thisgo back to Notepad, make some changes to the text, and save the file again. Go to your AutoCAD drawing and select View|Regen. The text item in the drawing updates to display the revised text from disk. Figure 3 shows Notepad with the new text superimposed on AutoCAD with the updated text item.
|Figure 3. If you change the text file, the drawing object automatically updates to follow it.|
As you've seen, Rtext lets you create a special text object that gets its contents from a text file on disk. The AutoCAD object automatically stays in step with any revisions to the disk file. It updates whenever you open the drawing and whenever the open drawing regenerates.
The first thing to notice is that the AutoCAD text object is not really an exact copy of the text file. For starters, it uses the AutoCAD text style and hence the font and size that are current when you create it. If you take a close look at the Command prompt area when you create an Rtext object, you see that you get two opportunities to change the style, the height, and the rotation angle of the text object. Those are the two occasions when I suggested you press <Enter> to take the defaults.
Next, Rtext does not format the text. A simple ASCII text file, as produced by Notepad, has no line wrapping. Figure 1 shows four lines of text, whereas figure 2 shows only two.
Notepad wraps lines to make them fit its current window size, but it does not apply any line-wrapping codes that carry over into AutoCAD. The AutoCAD object has two lines because I specifically put in a line break by pressing <Enter> in the Notepad file.
The good news is that any number of drawings can point to the same text file, and a single drawing can point to several text files. In both cases, everything updates automatically. You can use AutoCAD's Properties command to edit all the usual properties of an Rtext. In addition to the layer, size, text style, and so on, you can also change the text filename. You have to type in a specific path and filename, however, as Rtext does not bring up a file dialog box.
It would be nice to be able to do more text formatting in the text editor. Notepad is not going to cut it. Wordpad appears to work until you try to save your text. Although Wordpad supports several different file formats, the only one that Rtext supports is an ASCII text file. In this mode, Wordpad strips all formatting and special characters just before it saves the file.
How about using a full-fledged word processor such as Word or WordPerfect?
|Figure 4. You can use a word processor to get proper line wrapping. Just save as a text file with line breaks.|
As figure 4 shows, you can get automatic line wrapping in Rtext by using a word processor, subject to two limitations. First, Rtexts ASCII text file requirement still applies. Fortunately, most word processors have a Save As option that lets you save it as a text file with line breaks. This is the option you need to use. The other problem is that Word invokes file locking, which Rtext honors. You must close the document in Word before Rtext updates properly, then reopen it if you want to do more editing.
The only other significant factor to notice is that Rtext creates a unique, specific type of object in the drawing. If you send a copy of the drawing to someone else, you must also send the text file, and they must have Rtext installed. On the other hand, AutoCAD's standard Explode command will turn the Rtext object into standard text.
wait, there's more!
Notice the initial prompt when you start Rtext. If you enter a single letter
D, the Rtext object does not have to point
to an external file. It can contain text in the format of a Diesel programming
string, which also executes and hence updates the Rtext object automatically.
You can use this to do things such as generate an always-current list
of the xrefs attached to a drawing, include the filename and current drive
and directory path in the title block, or display the time and date on
A full treatise on Diesel is beyond the scope of the current column, but the Express Tools Help facility gives several interesting and useful examples.
now for something completely different
There is a simple trick to coming home from Las Vegas with a small fortune. Go there with a large one.
|Express lane to Express Tools|
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!