How to build your own synchronizer

One of the common requests is how to automate the loading of an iModel.

The iTwin Synchronization Portal allows WIP or Published models to be published into an iModel, but generally with large projects the requirements are changing by the hour.  Keeping up with this can be challenging.

The underlying technology of publishing to an iModel is the iModel Connectors. These can be loaded locally using the iTwin Synchronizer Client, but any connector can also be ran locally using the command line.

%LOCALAPPDATA%\imodelbridges\<Required Bridge>\iModelBridgeFwk.exe

Some of them have some esoteric requirements, but generally they are standardized.

To enable an iModel to be built from a saved search:

  1. Create a saved search in ProjectWise
  2. Using the PowerShell commands set a local export location
    $LocalExportLocation = 'F:\Temp\PW\Sync'
  3. Connect to ProjectWise
    New-PWLogin -DataSourceName "" -username "" -Usegui
  4. Copy out the documents discovered in the search
    get-pwdocumentsbysearch -SearchName  'DentalModels' -Personal | CheckOut-PWDocuments -copyout -ExportFolder $LocalExportLocation
  5. Load the top level documents into a variable
    $ProcessDocuments = get-pwdocumentsbysearch -SearchName  'DentalModels' -Personal
  6. Process them 

A command file is used invoke the connectors but this is personal preference as attempting to debug the command line with PowerShell I found frustrating.

The full command file for Microstation is here:

"C:\Users\Glen.Worrall\AppData\Local\imodelbridges\iModelBridgeForMstn\iModelBridgeFwk.exe" ^
--server-repository=Dental_Practice ^
--server-project=BSY_iModel_Samples ^
--fwk-input="%1%" ^
--fwk-staging-dir=F:\staging\Temp ^
--fwk-bridge-library="C:\Users\Glen.Worrall\AppData\Local\imodelbridges\iModelBridgeForMstn\DGNv8BridgeM02.dll" ^
--fwk-create-repository-if-necessary ^
--server-environment=RELEASE ^
--fwk-assetsDir="C:\Users\Glen.Worrall\AppData\Local\imodelbridges\iModelBridgeForMstn\Assets" ^
--fwk-logging-config-file="C:\Users\Glen.Worrall\AppData\Local\imodelbridges\iModelBridgeForMstn\Assets\" ^
--fwk-skip-assignment-check ^ ^

Note the password is protected by setting an environment variable, which does need to be a connect password rather than a domain password.

When it runs you should have an iModel.

BulbNote the document location is determined by the folder used to copy out the ProjectWise documents.

Use ProjectWise Directly

The connectors also allow a ProjectWise GUID to be passed to them. Therefore, if we wanted to have the PW link, we need to set the DMS parameters.

--dms-inputFileUrn="%1%" ^
--dms-user="" ^
--dms-type="1" ^
--fwk-staging-dir=F:\staging\PWTemp ^
--dms-workspaceDir=f:\staging\workSpace ^

Modify the PowerShell script accordingly:

 And we have the same iModel.

This time with links back to the pw repository.

Use a Connection and Web Services Gateway

Dave Brumbaugh has also added the capability to build a connection directly and populate an iModel. In this case we can add an iModel or use an existing iModel:

$docs = get-pwdocumentsbysearch -SearchName  'DentalModels' -Personal
$iModelConnections = Add-ImodelConnection $docs -iModel $iModel -OIDCToken $oidcTokenIMS -WSGURL ""

ProjectWise for PowerShell also allows the connection to be ran as well as automating the creation of a named version, but in this case, we can create this ready to be ran or scheduled as required.

However, we build the iModel, the results should be the same.

The queries above are ran against two different iModels and show we have the same categories and same geometric elements.

iTwin technologies are extremely flexible and are developed to enable engineering content from multiple sources to be published into an iModel.

While we show here how to use ProjectWise to build your own iModel from a saved search, the source of the engineering content can be most shared data repositories.

Thanks to Dan Cutler and Dave Brumbaugh for their assistance with this article.