A Step-by-Step Guide for Advanced Pen Table Text Substitution

The following is concise step-by-step guide to using named expressions with pen table text substitution to access print definition properties that are not available via other means. This includes separate print size X and Y values, and the print rotation. These strings are not available as standard print accounting variables.

This article applies to MicroStation V8i.

- Open (or create) a DGN library that is part of your project.

- Open and close the Print dialog. This step is required to register the print set symbol provider -- allowing PrintSet and PrintDefinition symbols to be visible inside the Named Expression editor.

- Open the Named Expression Editor via 'Utilities / Named Expressions'.

- In the Named Expressions dialog, choose 'Utilities / Report Symbols'. This brings up a report in Internet Explorer displaying all of the available symbols for use in expressions and their usage. Click each symbol name for more information. Note the HTML file name displayed in the address bar. You may wish to copy this file to a more convenient location for future reference.

- In the symbol report, search for the PrintDefinition and PrintSet categories and note the various symbols that are available. For the most part, they correspond to properties visible in the Print dialog and in Print Organizer. The symbols this article uses are PrintDefinition.SizeX, PrintDefinition.SizeY, and PrintDefinition.RotationDeg.

- In the Named Expressions dialog, select the New icon. For both 'Internal Name' and 'External Name', enter "PenTableTextSubst". (You can use whatever name you like). You can enter a helpful description if you want, such as "This expression is used by pen table xyz.tbl".

- For this purpose, it not necessary (or particularly desirable) to select any keywords.

- In the combo box to the right of the 'Required Symbol Sets' list, add 'PrintDefinition'. You must explicitly specify each category (e.g. symbol set) that you use in the expression.

- In the Expression edit field, enter

"Size: " & PrintDefinition.SizeX & "x" & PrintDefinition.SizeY & "; Rotation: " & PrintDefinition.RotationDeg

Make sure you enter the string correctly, including the quotes. Select the Test button; you should see "Size: 0x0; Rotation: 0" appear to the right of the button.

- Select the Save icon on the Named Expressions dialog.

- Save and close the DGN library.

- Open (or create) a design file. Make sure to use a project that includes the DGN library you just edited.

- Create a text element with the string "$SubstituteMe$" (do not include the quotes).

- Open the Print dialog. Choose 'Pen Table / Edit'.

- On the Modify Pen Table dialog, select 'Text Substitutions...'

- On the 'Text Substitutions' dialog, select 'Edit / Insert New'.

- With the single row in the substitution list selected, change the Actual string from "Original" to "$SubstituteMe$" (do not include the quotes). For the Replacement string, enter "<expr?name=PenTableTextSubst>" (do not include the quotes).

- Print or preview the design. The printed text should read something like "Size 11x8.5; Rotation: 0" (results will vary depending on your print layout).

For simplicity in this guide, I only created one expression that made use of a combination of multiple symbols and literal strings. It's equally valid to use multiple expressions, and insert them in between literal strings in the pen table replacement string. For example, the pen table replacement string could be "<expr?name=PrintSizeX>, <expr?name=PrintSizeY>, <expr?name=PrintRot>". That will yield a comma-separated list of the desired values, assuming that the expressions exist and each contains nothing more than the appropriate PrintDefinition symbol. The choice of which technique to use depends on your personal preferences.

For more information, see the pen table text substitution documentation and the named expressions documentation. Note that use of named expressions is not the easiest way to perform print text substitution, but is more flexible than the predefined replacement strings and less complicated than writing a BASIC macro or custom MDL plot hook function.

You may also gain insight by reading the 'Named Expressions in Conjunction with a Pen Table' section of this blog article: http://communities.bentley.com/Other/Old_Site_Member_Blogs/Bentley_Employees/b/andrew_edges_blog/archive/2008/08/31/Print-Text-Substitution.aspx.

Named expressions are also discussed in this blog article: http://communities.bentley.com/Other/Old_Site_Member_Blogs/Bentley_Employees/b/andrew_edges_blog/archive/2008/07/20/Tutorial_3A00_-Including-the-Date-in-Print-Output-File-Names.aspx.


(Please post any comments about this article in the MicroStation V8i - Printing forum).