AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Rtext and Drawing Setup
(This may even work with AutoCAD LT)

Note: You must have Express Tools installed within AutoCAD for the examples in this tutorial to function correctly or to even make sense. Express Tools are installed by default in AutoCAD 2000, 2000i and 2004 but not in 2002. If you would like Express Tools for AutoCAD 2002, you can install them from here.


Personally, I believe that Rtext is one of the best functions within the Express Tools Suite.
In this tutorial, we are going to have a look at how Rtext can help us with our drawing setups along with a few other little things.

Firstly, you need to download this zip file that contains a drawing named "Rtext_Setup.dwg", three sample Xref drawing files,  as well as a text file entitled "Notes.txt".
Place them all in a directory within your AutoCAD support path and then open the drawing "Rtext_Setup.dwg.

Let's have a look at the Title Block Data. Open up the "Drawing Properties" dialog. (File -> Drawing Properties). Choose the "Summary" tab. It should look like this :

Change the value of the "Title" edit box. Now choose the "Custom" tab.



Change a few of the entries in the "Value" edit boxes.
DO NOT change the values in the "Name" edit boxes.

Now, close the "Drawing Properties Dialog, zoom into the title block and Regen the drawing.

Did you see the values in the title block update to suit the changes you made?


Zoom into the lower right of the drawing. You should see this, although I've rotated it for clarity :

Hey thanks Kenny!!! A lovely little plot stamp. Regen the drawing after a minute or so and watch the time update automatically.


Now zoom into the lower left corner of the drawing :

 

This is a list of all the Xrefs that are attached to this drawing. To test it, Detach one of the Xrefs from the drawing and Regen the drawing. The list will update.


Now open up the text file "Notes.txt" within Notepad and make a few changes to the notes. Save the file and return to the drawing. Again Regen your drawing, and again watch the notes automatically update.

 

All of these magic tricks were achieved by using the Rtext function along with a few Diesel expressions. Let's now have a wee bit of a closer look!!


Reactive text (RText) objects are displayed the same way normal Text or MText objects are displayed, but the source for the text is either an external text file or the value of a DIESEL expression. You can edit an RText object with the RTEDIT command.

Command: RTEXT
Current text style: STANDARD  Text height: 0.2000  Text rotation: 0
Enter an option [Style/Height/Rotation/File/Diesel] <Diesel>: Specify an option

Options
Style Select a text style.
Height Specify a text height.
Rotation Specify a rotation value.
File Use an external text file.
Diesel Use DIESEL code.

Tip:
Once you have created an RText object with the File option, you can identify the associated text file with the LIST command.

Note:
If a drawing with an RText object is opened on a computer that does not have RTEXT installed, the proxy object that results displays the bounding box of the RText object. If you plan to send your drawing to someone who does not have RTEXT, you can explode the RText objects to MText objects with the EXPLODE command.

You can use an RText object as a file reference to display text, such as a sheet note or a legal disclaimer, that is common to several drawings. You can also use it to display larger bodies of text such as specifications or assembly instructions.


Here are some examples of how RText objects with DIESEL expressions can be used in your drawings.

To display the drawing name:

Drawing file: $(getvar, "dwgname")

Output:
Drawing file: 102-fp12.dwg

To include the directory path with the file name:
Drawing name: $(getvar, "dwgprefix")$(getvar, "dwgname")

Output:
Drawing file: C:\Projects\97-102\Arch\102-fp12.dwg

Note:
If you reference the drawing path or name in a standard title block, it will always display the file name of the drawing, even if the title block appears in an Xref file.

When you plot a drawing, you may want the hard copy to show the date and the time that the plot was created. The following DIESEL expression displays this information in your drawing:

$(edtime, 0, MON DD","  YYYY - H:MMam/pm)
Output:
Mar 22, 2000 - 11:12pm

The $(getprop) DIESEL function

RText supports Drawing Properties through a locally defined $(getprop) DIESEL function. With $(getprop), values from Drawing Properties dialog box tabs can be extracted and displayed in RText objects.

The syntax for the $(getprop) DIESEL function is:

$(getprop, property name)

where property name; can be any of the following fields from the DWGPROPS command:
Title
Subject
Author
Comments
Keywords
LastSavedBy
Revno
Custom Property  the name of a custom property

For example, if the Drawing Properties for a drawing contains the text "Excavated Site"
is the Subject, the DIESEL expression:
Subject: $(getprop, subject)

in an RText object will display as:
Subject: Excavated Site

Note:
The $(getprop) DIESEL function is supported only in RText objects. Unlike arguments supplied to other DIESEL functions, arguments to $(getprop) cannot be quoted. Arguments are not case sensitive.

If you have a custom property named "Project Name", the following DIESEL expression will display the value:

Project: $(getprop, %PROJECT NAME)

Note:
Errors in using $(getprop), such as improper syntax or bad arguments, will display (GETPROP ERROR). If a nonexistent custom property name is used, $(getprop) will display an empty string.


The $(xrefs) DIESEL function

RText supports listing Xref files attached to a drawing through the $(xrefs) DIESEL function.

The syntax for the $(xrefs) DIESEL function is:

$(xrefs [, flags [, leader [, trailer]]])
flags A collection of bitflags with the following meanings:
1 = (default) include Xref file name (not exclusive with flag 2)
2 = include Xref block name (not exclusive with flag 1)
4 = don't display file name extension
8 = don't display path
16 = show nesting with additional spacing
leader A text string inserted before each Xref entry.
trailer A text string appended to each Xref entry except the last.

Example:
The RText DIESEL expression:

$(xrefs,3)

displays a list of Xrefs in the following format:
B-ELEC [c:\proj-14\b-elec.dwg]
M-ELEC [c:\proj-14\m-elec.dwg]
R-ELEC [c:\proj-14\r-elec.dwg]
F-ELEC [c:\proj-14\f-elec.dwg]
while the expression:
$(xrefs,2,Includes: )

will list the Xrefs as:
Includes: B-ELEC
Includes: M-ELEC
Includes: R-ELEC
Includes: F-ELEC

The $(images) DIESEL function

RText supports listing images attached to the drawing through the $(images) DIESEL function.

The syntax for the $(images) DIESEL function is:

$(images [, flags [, leader [, trailer]]])

flags A collection of bitflags with the following meanings:
4 = don't display file name extension
8 = don't display path
leader A text string inserted before each Image entry.
trailer A text string added each Image entry except the last one.
Behavior is similar to the $(xrefs) function.

The $(getrec) DIESEL function

RText supports displaying Xrecord data through the $(getrec) DIESEL function.

The syntax for the $(getrec) DIESEL function is:

$(getrec, key, code)

key Entry name in the Named Object Dictionary.
code Group code to extract.

The $(getrec) function extracts a value from an Xrecord by looking in the Named Object Dictionary for key, then for a data value associated with code. Currently, only group codes in the ranges 1-9 (string), 40-59 (real), 60-79 (integer) and 300-309 (string) are supported. 
 
The AutoLisp/Visual Lisp/VBA Resource Website

Copyright 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website