Original Article Date: Feb 1, 2001
Last month, we talked about getting started with a customized workspace. This month we’ll look at creating a configuration file. The configuration file is the heart of a customized workspace because it tells MicroStation where to find all your resources and directories. In this column, we will walk through the process of creating a configuration file. The first step is to do an analysis of existing resources. The next step is to create a configuration file. The last step is to use the debugger in MicroStation to make sure the configuration will work. 2001-02-01 Originally published on MSMonline 2006-03-20 Aquired and posted on AskInga
Analyze this data In this scenario, analysis reveals that our example firm has some CAD standards in place. Standard data and resource files can be found on S:\ drive while project related data are stored on P:\ drive. Here is a table listing the resources that we have to work with.
The table contains four types of information for each of the CAD standards: 1. A brief description of the standard. 2. The associated MicroStation variable. 3. CAD Standard filename or directory. 4. Where the Standard will be defined. The first variable, _USTN_PROJECTSROOT, looks different from the others because it begins with the underline character ( _ ). The underline character means the item is a MicroStation system variable. These variables are hidden when using MicroStation to view the Configuration Variables dialog. _USTN_PROJECTSROOT defines the location for the Project Configuration Files and project directories. The next five variables are self-explanatory. The MS_USERNAME variable sets the MicroStation username to the system username. In this example we are using a Windows NT system. When I log in the username variable is set to mramsey. Therefore, mramsey.ucf (User Configuration File) must exist in the C:\Bentley\Workspace\users directory. I created one by copying C:\Bentley\Workspace\users\untitled.ucf and renamed it mramsey.ucf. The last five variables are also self-explanatory. Rules for configuration files Before creating a configuration file, review configuration variable file syntax or rules of order. Configuration variable definitions utilize operators: Configuration Variable Operators . We’ll examine four operators: =, >, <, and : . In the text below, the pound sign (#) identifies a line that will be ignored by MicroStation; use it for comments. # assigns a new value to the variable MS_CELL = s:/cell/ Using the equal (=) sign removes any pre-existing values and makes the new value the only value. If MS_CELL had been previously defined, the old value is lost when the equal sign is used. # appends the directory or file lists defined by the new value MS_CELL > s:/cell/ The Greater Than sign (>) adds the new value to the end of the list. In our example, s:/cell/ will be added to the end of the list of directories for cell libraries. # prepends the directory or file lists defined by the new value MS_CELL < s:/cell/ The Less Than sign (<) adds the new value to the beginning of the list. s:/cell/ will be added to the beginning of the list of directories for cell libraries. Now it will be the first directory to be searched. : assigns a new value to the variable only if that variable does not already exist MS_CELL : s:/cell/ The Colon (:) sign assigns a new value only when the variable does not have an existing value. In our example, MS_CELL would be ignored since MicroStation would have already assigned a value. Tip: Don’t forget to end any directory definitions with a trailing slash. In configuration files, be sure to use forward slashes (/) instead of the backslash (\). This method allows the configuration file to be compatible across different platforms. DOS and Windows NT will convert the forward slash to a backslash. Create the Configuration File The next step is to create a configuration file based on our analysis. Remember, anything on a line after a pound sign (#) is considered a comment. Include as many detailed comments as possible to show what you did and why you did it. # Site configuration file # MAR 11.15.2000 # Version 1.0 # Directory for project configuration files _USTN_PROJECTSROOT = p:/ # Directories where cell libraries can be found MS_CELL < s:/cell/ # Cell libraries to search for cells MS_CELLIST < s:/cell/*.cel # Directories where seed files can be found MS_SEED = s:/seed/ # Default seed file MS_DESIGNSEED = s:/seed/3dseed.dgn # List of font resource files MS_SYMBRSRC = s:/symbology/*.rsc # Define the MicroStation username to the NT system username _USTN_USERNAME = $(USERNAME) # Directories where design files can be found MS_DEF = p:/$(_USTN_PROJECTNAME)/ # Directories where reference files and standard border files can be found MS_RFDIR = p:/$(_USTN_PROJECTNAME)/ Notice the last two configuration variable definitions, MS_DEF and MS_RFDIR. A variable definition can include a defined variable definition. MicroStation will find the definition of _USTN_PROJECTNAME and include it in the new definition. If _USTN_PROJECTNAME = project1 then MS_RFDIR = p:/ project1/. Tip: Keep variable names in uppercase and definitions or new values in lower case. This makes it easier to read the variables.
Projects need configuration too Remember the analysis we suggested at the beginning of this article? We decided that a couple of the variables would be used at the project level. Until now, everything had been at the site level. Directories for the design and reference files will change depending on the project. Let’s create a project configuration and then get MicroStation to read it. My project directory is called frommer. I’ll create a Project Configuration File called frommer.pcf and place it in the project drive. # Directories where design files can be found MS_DEF = p:/$(_USTN_PROJECTNAME)/ # Directories where reference files and standard border files can be found MS_RFDIR = p:/$(_USTN_PROJECTNAME)/ I’ll create a Project Configuration File for each of my projects. Each project will be included in the MicroStation Manager dialog. Implement the configuration file We will include the new configuration file so that MicroStation will read it. There are two ways to do this, local or network. To implement it locally, place the file in the C:\Bentley\ Workspace\standards directory. Name the new file zstandards.cfg so it will be read in after standards.cfg. To implement this on the network add the file zstandards.cfg to the C:\Bentley\Workspace\standards but with just one line: % include s:/site.cfg MicroStation will read zstandards.cfg where the include command will force it to then read s:/site.cfg. Run Debug From The Command Prompt DOS Window Test the configuration file and see if there are any errors in the process. To do this you should have a MicroStation icon on your desktop. Right-click on the icon and select Properties. In the target field, add -debug to the end of the line. Click OK to exit. Now double-click on the icon. A text window will open while debug runs. Press the enter key to dismiss the window. If the debug was successful a message similar to this will appear: Debugging output saved to msdebug.txt. If the debug session was not successful you’ll see an error.
In this case, the error is telling you that MicroStation cannot find the file s:\site.cfg. You will have to figure out why the file can’t be found. It could be the network connection was not defined or the filename is incorrect. Make the correction and debug again. This is the most powerful tool you have when creating configuration files. We can’t stress how important it is for you to use it! The debug program writes all its data to msdebug.txt and places the file in the MicroStation directory or C:\Bentley\Program\ MicroStation. Double-click on the filename to open or use your favorite text editor to open the file. Even if your debug session ends in an error, you can open the file and see how far the debug progressed. You’ll see each configuration file and the way MicroStation processes all the variable definitions. The best part is at the bottom of the file. Here you will find a listing of all defined variables. Final thoughts As with everything else in MicroStation, there is more than one way to create a custom workspace. Now that you’ve seen one method, go out and experiment. You are bound to discover more ways of customizing with environment variables.
AskInga Article #292