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:
$LocalExportLocation = 'F:\Temp\PW\Sync'
New-PWLogin -DataSourceName "decide-pwce-eu.bentley.com:decide-pwce-eu-09" -username "glen.worrall@bentley.com" -Usegui
get-pwdocumentsbysearch -SearchName 'DentalModels' -Personal | CheckOut-PWDocuments -copyout -ExportFolder $LocalExportLocation
$ProcessDocuments = get-pwdocumentsbysearch -SearchName 'DentalModels' -Personal
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\iModelBridgeFwk.info.logging.config.xml" ^--fwk-skip-assignment-check ^--server-user=glen.worrall@bentley.com ^--server-password=%PRODPASS%
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.
Note the document location is determined by the folder used to copy out the ProjectWise documents.
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="glen.worrall@bentley.com" ^--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.
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 "https://decide-pwce-eu-ws.bentley.com/ws"
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.