The general architecture and main components used by a MicroStation based application to publish an i-model using data generated by a 3rd-party application is depicted in the diagram below.
Using the SDK, the MicroStation App would perform the following tasks:
-
Creates a temporary DGN into which the graphics and business data to be published will be written. NOTE: If the source data is stored in a format which the host engine supports (e.g., DGN, DWG, etc.), the file(s) can be opened directly. In this case, the in-memory representation may need to be updated prior to publishing and steps need to be taken to ensure the source data is not changed.
-
To create a temporary DGN file, use the mdlWorkDgn functions. The name assigned to the DGN should be that of the i-model to be created.
-
To open file, use the mdlWorkDgn_openFile function. Once the file is open then use the SessionMgr to select the model reference to work on.
-
To avoid changing the source data set a "Mark" in the file using the mdlUndo_mark function or using the ITxnManager class.
-
Reads the external graphics and business data using a method that is most appropriate for the format in which it is stored (e.g., 3rd party API, etc.).
-
If the source data is opened directly by the host engine, the SDK can be used to read its contents using the ElementGraphicsProcessor.
-
Creates and writes graphics to be published to the temporary DGN. NOTE: If the source data is loaded directly by the host engine, the graphics will already be loaded into memory and can be manipulated if required and published.
-
Use the MicroStation API for graphics creation.
-
Creates and writes the business schema and data to the temporary DGN. NOTE: If the source data is loaded directly by the host engine, this step is still required since the business data needs to be stored in the required format. In this case, the in-memory representation will be updated. To avoid duplication of data, the source data (e.g., element tags, user-defined fields, etc.) should be removed using applicable functions in the MicroStation SDK.
-
Publishes the i-model using the temporary DGN as the source. NOTE: If the source data is loaded directly by the host engine, the in-memory representation will be published.
-
Obtain a reference to the i-model publising publisher using the IModelPublisher::Create method.
-
Set the publishing options using the class IModelPublishOptions. To get a reference to this class, get the PublishOption from the IModelPublisher class.
-
Set each option using the method specified for that setting.
-
If the file being published is not the original source file, register an OverrideProvenanceSourceEvent function using IModelPublisher::SetOverrideProvenanceSourceEvent method to assign the correct source provenance information. Recall, i-models must reference the original source of data. By default, the file published is defined as the source, which in this case would be either the temporary DGN or source file opened directly. In the former case, the temporary DGN is not the original source, but rather an immediate file into which the source graphics and data are written and published. Resetting provenance to include information on the original source of data is handled using the mentioned call-back mechanism.
-
Invoke the publishing process by calling the Publish method on the IModelPublisher class.
-
Reset provenance if required to include the original source of data via the call-back function mentioned above.
The libraries required for this use case are:
-
Bentley.XmlInstanceNative.lib
-
Bentley.ProvenanceNative.lib
-
Bentley.Publish.lib