Import and export Modelbuilder connections with a Modelbuilder Connection File

  Applies To 
  Product(s): WaterGEMS, SewerGEMS, CivilStorm, StormCAD, SewerCAD, HAMMER, WaterCAD
  Version(s): 08.11.04.XX+, 10.XX.XX.XX
  Original Author: Mark Pachlhofer, Bentley Technical Support Group


What is a ModelBuilder connection file (MBC) and can it be shared?

How can I copy or share my ModelBuilder connections?


After a ModelBuilder run has been created (see images below) a user can choose to export the properties of the run by clicking the 'Export Connection button'. ModelBuilder will create a .MBC file that can be shared with colleagues by using the "Import Connection" feature. Note:

  • The MBC file will contain all Modelbuilder connections seen in the Modelbuilder manager
  • Paths to local files will need to be re-mapped on other computers. The source files themselves are not included in the MBC file. For example, if the connection was to a spreadsheet stored in "My Documents", then after importing the MBC file on another computer and attempting to use that connection, you'll be prompted to re-select the file.


ModelBuilder Connection Batch Import

A new batch import tool is now included for use in the Command line (CMD) on your computer. This allows for a faster import of .MBC files into ModelBuilder and more efficient model building workflows when using existing ModelBuilder connections.

  • As of May, 2018, this feature only supports importing data (the equivalent of "Build model" (Sync in to model) in ModelBuilder). Sync out (export to an external file/database) is not yet supported.
  • For Oracle connections that require a password, you may encounter the error "Could not Import: Error: Object reference not set to an instance of an object.". This is due to the password prompt not appearing. This issue is resolved in a cumulative patch set for version (and included in later releases) where you can specify the Oracle password (for the command line tool to use), by setting an environment variable named MB_ORACLE_PW with a value set to the Oracle password. Note that this only applies to the command line batch tool - ModelBuilder in Standalone WaterGEMS will still request a password.

From the CMD dialog, you can enter the name of tool (Haestad.ModelBuilder.BatchImport.Driver.exe) followed by an input flag with semicolon-delimited .MBC files. To do this, first open a CMD line window. Then, enter the name of the import tool (Haestad.ModelBuilder.BatchImport.Driver.exe) (this will be in same directory as WaterGEMS executable), followed by an input flag (-i) with semicolon-delimited mbc files. One of two other flags are required: -n (for new) or -o (for output), where -n flags require the name of a new model (.sqlite file) which will be created with the imported data and -o flag requires the name of an existing model which will be updated with the imported data. (The order of the flags doesn't matter.)

The following are some examples of the syntax for some use cases:

Import one ModelBuilder Connection File to one new model:

  • Haestad.ModelBuilder.BatchImport.Driver.exe -n "C:\dev\newModel.sqlite" -i "C:\dev\myMbcFile.mbc"

Import multiple ModelBuilder Connection Files to new model:

  • Haestad.ModelBuilder.BatchImport.Driver.exe -n "C:\dev\newModel.sqlite" -i "C:\dev\myMbcFile.mbc";"C:\dev\myOtherMbcFile"

Import to an existing model:

  • Haestad.ModelBuilder.BatchImport.Driver.exe -o "C:\dev\existingModel.sqlite" -i "C:\dev\myMbcFile.mbc"

Select Series 3 and earlier

Each time you set up a ModelBuilder connection, it is saved in the list seen in the main ModelBuilder window. This window is what is first displayed when you open ModelBuilder (Tools > ModelBuilder).  This list of connections is saved in a file called Modelbuilder.xml. The connections in this file will appear for any model on that computer. To move, copy or share the Modebuilder connection information, you'll need to copy that Modelbuilder.xml file to the other computer, then restart the OpenFlows product. Be sure that version of the OpenFlows product is the same on that computer. For instance, make sure WaterGEMS V8i SELECTseries 4 (build is installed on both computers.

The location of the Modelbuilder.xml file depends on the operating system:

Windows XP: C:\Documents and Settings\(user profile name)\Application Data\Bentley\WaterGEMS\8\

Windows Vista and Windows 7: C:\Users\(user profile name)\AppData\Roaming\Bentley\WaterGEMS\8\

See Also

Building a model using ModelBuilder