Q Here are some common questions about MicroStation configuration files and configuration variables …

A Questions similar to these pop up regularly on the Bentley Discussion Groups. You can view configuration files interactively through the Workspace Configuration dialog, accessible via MicroStation's Workspace Configuration menu. However, this does not normally display hidden CfgVars, and is not convenient if you're attempting to determine the relationship between variables, or how one variable is defined in terms of another.

MicroStation uses configuration variables (CfgVars) to specify data files, locations for files, and file search paths. CfgVars are defined in the configuration files specified for your MicroStation workspace. These may include a user workspace (.ucf file), project workspace (.pcf file), or one of the many plain old configuration (.cfg) files used when customising your MicroStation environment. All configuration files are plain text files.

FlexiTable

FlexiTable™ has many uses in acquiring and exporting data from MicroStation. You can read the configuration variables of your active workspace into a FlexiTable worksheet. FlexiTable automatically validates CfgVar path and file variables. You can expand multi-path variables to see each path individually and determine whether it is valid. Finally, you can save the worksheet in Excel format …

Configuration Variables in FlexiTable

FlexiTable™ is a licensed product developed and sold by LA Solutions. There's more information about FlexiTable.

Validate a Configuration Variable

A CfgVar may be defined correctly but nonetheless point to an invalid file or folder. It's difficult to detect this condition, which may result from a minor spelling mistake that is hard to spot.

Imagine that we have this scenario, where MS_CELL is pointing to …

V:\Projects\Workspace\Standards\cells\

but the actual directory name is this (note that the final s is omitted) …

V:\Projects\Workspace\Standards\cell\

This mistake is difficult to detect, because the variable looks right and MicroStation's debug output also looks right. What you want is something that will analyse a troublesome CfgVar and tell you if it's defined correctly.

Configuration Validator tool

We wrote the Configuration Validator to help with this situation. It's a freeware tool that helps you, a MicroStation CAD Administrator, to debug your configurations.

Alternatively, if you would like to purchase a tool for the job, FlexiTable can also list and validate configuration variables.

MicroStation Configuration Variables in V8

Bentley Systems continue to add new configuration variables to Microstation. This page on the Bentley web site list new variables.

Show the Value of a Configuration Variable

If you want to get information about all configuration variables in the current workspace, use MicroStation Debug. If you want to show the value of a single configuration variable, use keyin …

EXPAND ECHO $(variable name)

For example, to show the value of configuration variable MS_DEF, use this keyin …

EXPAND ECHO $(MS_DEF)

MicroStation Debug

One of MicroStation's command-line switches is -debug. This dumps configuration variables to a text file msdebug.txt and exits MicroStation. This file provides a detailed listing of CfgVars and how the value of each is derived. However, it does not tell you the purpose of each variable: for that, you must look in the MicroStation Administrator's Guide, or dump the Configuration Variable Names.

Here's a fragment of msdebug.txt created on my computer. The entire file is too big to be included here, and yours is guaranteed to look different …

Processing macro file [G:\PROGRA~1\Bentley\Program\MICROS~1\config\mslocal.cfg]
(system): MSDIR=G:\Program Files\Bentley\Program\MicroStation\ [G:\Program Files\Bentley\Program\MicroStation\]
(system): _USTN_WORKSPACEROOT=G:\Program Files\Bentley\Workspace\ [G:\Program Files\Bentley\Workspace\]
(system): MS_TMP=$(TEMP) [D:\TEMP]

Where is msdebug.txt Created?

MicroStation CONNECT

The location of msdebug.txt, by default, is the folder where MicroStation.exe is found, probably. Your installation may differ …

#  MicroStation CONNECT
C:\Program Files\Bentley\MicroStation CONNECT Edition\MicroStation
MicroStation V8

The location of msdebug.txt, by default, is the folder where ustation.exe is found, probably …

#  MicroStation V8i
C:\Program Files (x86)\Bentley\MicroStation
#  MicroStation XM
C:\Program Files (x86)\Bentley\MicroStation
#  MicroStation V8
C:\Program Files (x86)\Bentley\Program\MicroStation

Another place is may appear, depending on your version of Windows, is …

C:\Users\ user name\Local Settings\Temp\

Where user name is your Windows account user name. Thanks to Simon Wurster of URS for that hint!

If you set a Windows environment variable called MS_CFGVAROUT to a directory, it will go to that directory. For example …

set MS_CFGVAROUT=D:\temp\
ustation.exe -debug

However, if you have started MicroStation from a Windows shortcut that specifies a Start In location, then msdebug.txt will be created in that folder.

MicroStation V8i SS3 Enhancement

From SS3 Bentley Systems have added an option to the debug switch that will make viewing the resulting file much easier. There's a new option
ustation.exe -debugfileopen = #

The new option works exactly like the old but it opens the msdebug.txt file in the associated application.

Configuration Variable Names

To get a listing of all of MicroStation's Configuration Variables, invoke this command in MicroStation's keyin dialog …

mdl load cfgvars printCfgVarResource

The product of this command is two text files, cfgvars.txt and cfgvlong.txt. These files describe all the CfgVars known to MicroStation. However, the command does not describe CfgVars that are not part of MicroStation (i.e. those that you have defined), nor does it display the value of each CfgVar. If you want to see the value of a CfgVar, either browse the Workspace Configuration or use MicroStation Debug to create a searchable text file.

The files are too large to be included here, but a snippet from cfgvars.txt is shown below. Note that hidden configuration variables are documented …

----------------------------------------------------------------------------------------------------------
| Cfg Var Name             | Type           | Short Description              | Restart   | Project    |
----------------------------------------------------------------------------------------------------------
| MS_USERPREF_APPS         | Filelist       | User Preference Applications   | YES       | NO         |
| MSDIR                    | Directory      | MicroStation Dir               | YES       | NO         |
| MSLOCAL                  | Directory      | MicroStation Dir (Local)       | YES       | NO         |
| _USTN_DEFUSERINTNAME     | Directory      | Default Interface Subdirectory | YES       | NO         |
| _USTN_USERINTNAME        | Directory      | Interface Subdirectory         | YES       | NO         |

The file location of cfgvars.txt and cfgvlong.txt, by default, is the folder where ustation.exe is found, probably …

#  MicroStation XM
C:\Program Files\Bentley\MicroStation
#  MicroStation V8
C:\Program Files\Bentley\Program\MicroStation

However, if you have started MicroStation from a Windows shortcut that specifies a Start In location, then cfgvars.txt and cfgvlong.txt will be created in that folder.

Hidden Configuration Variables

MicroStation has many CfgVars that are hidden from the Workspace Configuration dialog, simply by prefixing the variable name with an underscore character. For example, _USTN_WORKSPACEROOT, where MicroStation looks for user and project workspace files. You can enable the display of hidden CfgVars in the Workspace Configuration dialog by defining the _USTN_DISPLAYALLCFGVARS variable.

Setting _USTN_DISPLAYALLCFGVARS = 1 will list all available CfgVars, including the _USTN_XXX variables, in the Workspace Configuration dialog. You can create a file containing a list of CfgVars, including hidden ones, using the print CfgVar resource command.

MicroStation Fails to Process a Configuration File

This has been an issue with configuration files for a long time: if there is no carriage return after the last line in a configuration file, then MicroStation won't process the file correctly. Depending on the version of MicroStation you have, the failure ranges from ignoring the file to catastrophic program crash.

Because a carriage return is white space, it's sometimes difficult to spot. It's certainly difficult to illustrate on this web page! Here's an attempt to illustrate the problem. The following snippet from a .pcf file has no line-feed character …

#  This is the last line of a configuration file, and has no end-of-line carriage return

The following snippet from a .pcf file has a line-feed character after the comment …

#  This is the last line of a configuration file, which has an end-of-line carriage return

Did we illustrate the problem successfully?