Xdata for element in OpenDesignFileForProgram

Fellow Microstation VBA users,

I neeed some basic code to add/modify Xdata for an element, in a cell, in a design file, opened with OpenDesignFileForProgram.  I'm uncertain how to do this.  My guess would be to utilize the Appplication.ObjectConnector or the mdlModelRef_loadReferenceModels?

Thanks in advance,

Christmas May

Parents
  • Also note:  The following code works when ran on an individual file.  However, it doesn't work when run via "Batch Process"?

    Private Sub sRepairABC(gObjCell As CellElement)
       Dim sIntIndex
       Dim sBlnABC As Boolean
       Dim sObjTempElement As Element
       Dim sStrXdata As String
       Dim sAryXdatum() As XDatum
       Dim theID As DLong

       'Step through the cell
       gObjCell.ResetElementEnumeration
       sIntIndex = 0
       Do While gObjCell.MoveToNextElement
          sIntIndex = sIntIndex + 1
          Set sObjTempElement = gObjCell.CopyCurrentElement
          If sIntIndex < 9 Then
             sStrXdata = "A" & CStr(sIntIndex)
          Else
             sStrXdata = "B" & CStr(sIntIndex - 8)
          End If
          'Build the new XDatum array.
          'AppendXDatum sAryXdatum, msdXDatumTypeControlString, "{"
          InsertXDatum sAryXdatum, 0, msdXDatumTypeString, sStrXdata   'Append or Insert really doesn't matter.
          'AppendXDatum sAryXdatum, msdXDatumTypeControlString, "}"

          'Then put it onto the element.
          sObjTempElement.DeleteAllXData
          sObjTempElement.SetXData "RevABC", sAryXdatum
          'sObjTempElement.Rewrite
          gObjCell.ReplaceCurrentElement sObjTempElement
          DeleteXDatum sAryXdatum, 0
       Loop
       gObjCell.Rewrite
    End Sub

    Please help,

    Christmas May

Reply
  • Also note:  The following code works when ran on an individual file.  However, it doesn't work when run via "Batch Process"?

    Private Sub sRepairABC(gObjCell As CellElement)
       Dim sIntIndex
       Dim sBlnABC As Boolean
       Dim sObjTempElement As Element
       Dim sStrXdata As String
       Dim sAryXdatum() As XDatum
       Dim theID As DLong

       'Step through the cell
       gObjCell.ResetElementEnumeration
       sIntIndex = 0
       Do While gObjCell.MoveToNextElement
          sIntIndex = sIntIndex + 1
          Set sObjTempElement = gObjCell.CopyCurrentElement
          If sIntIndex < 9 Then
             sStrXdata = "A" & CStr(sIntIndex)
          Else
             sStrXdata = "B" & CStr(sIntIndex - 8)
          End If
          'Build the new XDatum array.
          'AppendXDatum sAryXdatum, msdXDatumTypeControlString, "{"
          InsertXDatum sAryXdatum, 0, msdXDatumTypeString, sStrXdata   'Append or Insert really doesn't matter.
          'AppendXDatum sAryXdatum, msdXDatumTypeControlString, "}"

          'Then put it onto the element.
          sObjTempElement.DeleteAllXData
          sObjTempElement.SetXData "RevABC", sAryXdatum
          'sObjTempElement.Rewrite
          gObjCell.ReplaceCurrentElement sObjTempElement
          DeleteXDatum sAryXdatum, 0
       Loop
       gObjCell.Rewrite
    End Sub

    Please help,

    Christmas May

Children
No Data