MicroStation CONNECT Edition Help

Simple Pen Table Text Substitution

Suppose you want the user name and the current date to appear on the printed output, the first step is to place two text elements in your DGN file containing $USER$ and $DATE$. The strings you use to identify the elements to be replaced can be anything you like, but they need to be unique. The second step is to use the Edit > Insert New menu item on the Text Substitutions dialog to insert two replacement pairs. Then for each replacement pair, enter both the original string to be replaced and the desired replacement string.



Text Substitutions dialog showing actual/replacement strings



Preview showing pen table text substitutions

In this example, two techniques for the replacement string are shown. For the date, one of the predefined replacement tokens (Edit > Insert Date) provided on the Text Substitutions dialog will be used. The predefined replacement tokens are easy to use, but have some limitations. The main limitation is that the replacement string can only contain one token, and it cannot be used in conjunction with literal text, environment variables, printing accounting variables, or named expressions.

By default, the formatting of the _DATE_ and _TIME_ replacement tokens are controlled by the Windows Regional and Language settings, but can be overridden via the MS_PENTABLE_DATE_FORMAT and MS_PENTABLE_TIME_FORMAT configuration variables, respectively.

For some of the predefined replacement tokens, the pen table offers different formatting variations. For example, each file name value (design file, pen table, printer driver configuration file) has separate tokens for the fully qualified file name, the base file name only, or an abbreviated version of the fully qualified file name. There are also long and short versions of the print scale.

For the user name, there is no predefined replacement token available; therefore, this example demonstrates how you can use the environment variable USERNAME, which is defined by Windows. Some literal text is also included in the replacement string to demonstrate the capability. You can also use multiple environment variables in the same replacement string, such as "$(USERDOMAIN)/$(USERNAME)" to yield "Bentley/Joe User."

If a replacement string or a portion of a replacement string has the format of a configuration macro — that is, $(text) — the string undergoes substitution automatically to a preset value. This automatic substitution is called expansion. For example, the string User: $(USERNAME) might expand to "User: Joe User."

If a string in configuration macro format is expanded to another configuration macro, substitution is iterative. That is, it continues until the resulting string does not contain a configuration macro.

You can also use any of the print accounting variables in the replacement string. The values of many of these variables are redundant with the pen table predefined replacement tokens, but have the advantage of being able to use more than one in a single text replacement string. For example, "Sheet $(MS_PLT_DOCSET_CURRENT_SETDOC) of $(MS_PLT_DOCSET_NUMSETDOCS)" may evaluate to "Sheet 1 of 20" when printing from Print Organizer.