TeamcenterKnowledge

MBSE Integration Services for Integrating Modeling Tools

bhmSaveBlockLibrary API

Use the following API to save and check in library models to Teamcenter.

List<BHMOperationOutput> bhmSaveBlockLibrary (List<String> dataSaveInputXML, String toolType)

Inputs

  • dataSaveInputXML — Specifies a list of input strings that are based on the BHMOperationsSchema.xsd file. You can generate the xml string using the JAXB utility available with the BHMOperationData and BHMDesign classes in the com.teamcenter.behaviormodeling.common.xml package.
  • toolType — Specifies the behavior modeling tool, for example, MATLAB.

In your Java code, you must specify the following:

  • In the BHMOperations element, specify the values for rootModelFolder, rootModelName, and rootModelIdentifier.
  • In the Model element: specify the values for modelName and modelIdentifier; specify the value of tcuid for an existing model, and do not specify it for new models.
  • In the Attributes element, specify the value of item_id for items and revisions. If not specified, Teamcenter automatically generates them. Do not specify tcrevId and tcitemId as they are for internal use.
  <Attributes>
    <Key name="item_id">
      <Value>001001</Value>
    </Key>
    <RevisionAttributes>
      <Key name=" item_id ">
        <Value>P</Value>
      </Key>
    </RevisionAttributes>
  </Attributes>

You can also specify a description for the model in the Attributes element as follows:

  <Attributes>
    <Key name="object_desc">
      <Value>This is S1 Desc</Value>
    </Key>
  </Attributes>
  • Specify the submodel information in the ModelElement element. Specify the ID and revision of the submodel in the Attributes element of ModelElement — if not specified, Teamcenter automatically generates them.
  • In the saveOperationOptions element, specify the values of the following variables:
    • folderUID — Saves the model to the Teamcenter folder specified by the folder UID.
    • checkIn — Checks in the root model when the value is set to true.
    • addAdditionalData — Attaches additional data when the value is set to true, and specify the additional data details in the AdditionalData element.

Outputs

The output is a list of BHMOperationOutput objects (com.teamcenter.behaviormodeling.common package). Each object corresponds to one of the input XML strings sent through dataSaveInputXML.

BHMOperationOutput variable Description
OperationStatus Returns one of: OPERATION_FAILED, OPERATION_WARNING, OPERATION_SUCCESSFUL, OPERATION_SUCCESSFUL_WITH_INFO
message Specifies the cause of the API failure.
inputXML Specifies the input XML string based on BHMOperationsSchema.xsd.
outputXML Specifies an XML string based on BHMDesignSchema.xsd.
rootModelName Specifies the root model to be saved.
rootModelIdentifier Specifies the identifier of the root model.
rootModelFullFilePath Specifies the complete path of the root model.

Example

To save a new library model to Teamcenter, you can pass the following string through the dataSaveInputXML list of the bhmSaveBlockLibrary API.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<BHMOperations xmlns="http://www.plmxml.org/Schemas/bhm"
  rootModelFolder="D:\Models\MatlabModels" rootModelName="MyModel"
  rootModelIdentifier="MyModel">
  <modelInfo>
    <Model toolId="" teamcenterVersion="1.1" tcType="Bhm0BehaviorModlRevision"
      tcItemName="MyModel" tcrevId="" tcitemId="" tcuid=""
      modelIdentifier="MyModel"
      modelName="MyModel">
      <Attributes>
        <Key name="object_name">
          <Value>MyModel</Value>
        </Key>
        <Key name="object_desc">
          <Value></Value>
        </Key>
        <Key name="item_id">
          <Value>000041</Value>
        </Key>
        <RevisionAttributes>
          <Key name="item_revision_id">
            <Value>A</Value>
          </Key>
        </RevisionAttributes>
      </Attributes>
      <AdditionalData>
        <File description="" relationType="Bhm0AdditionalData"
          reservation="true" path="D:\Models\MatlabModels\AdditionalData"
          fileext="txt" fileName="ReviewComments.txt" namedReferenceType="Text"
          tcDatasetType="Text" tcuid="" action="add" />
      </AdditionalData>
      <Contents>
        <ModelElements>
          <ModelElement parent="S1" tcType="Bhm0BehaviorModlRevision"
            instanceType="MATLAB:ModelReference" instanceUid="" tcuid=""
            modelIdentifier="MyChild" modelName="MyChild" name="Model">
            <Attributes>
              <Key name="object_name">
                <Value>MyChild</Value>
              </Key>
              <Key name="object_desc">
                <Value>This is MyChild Desc</Value>
              </Key>
              <Key name="item_id">
                <Value>001003</Value>
              </Key>
              <RevisionAttributes>
                <Key name="item_revision_id">
                  <Value>Q</Value>
                </Key>
              </RevisionAttributes>
            </Attributes>
          </ModelElement>
        </ModelElements>
      </Contents>
    </Model>
  </modelInfo>
  <options>
    <saveOperationOptions folderUID="" checkIn="true"
      addAdditionalData="true" />
  </options>
</BHMOperations>

Source: https://docs.sw.siemens.com/en-US/doc/282219420/PL20251212545240207.xid1913857/xid914160 · retrieved Fri Jul 10 2026 00:00:00 GMT+0000 (Coordinated Universal Time)