Set Revision through API
Posted: Mon Oct 04, 2021 3:46 pm
Hello,
I have an API that is supposed to be setting the PDM vault revision counter, and runs without error, but does not actually write the new revision value.
Background: I'm trying to set revisions for a vault of legacy data where the rev is stored in the custom properties via external PDM and PLM systems, but the actual vault PDM rev isn't set.
Code details: I'm pulling the correct legacy revision from the custom properties via Document Manager API (plus some additional user input when there are 2+ unique revs saved on the same file ), and reading the information for the revision counter name and value through the PDM API. A lot of the code in question is borrowed heavily from the "Set Initial Revision" Help example:http://help.solidworks.com/2020/english ... _VBNET.htm.
This seems to be the problem area:
I'm running out of troubleshooting ideas - there are debug statements every other line, and everything works perfectly right up to the set of write statements (RevMgr.IncrementRevision, RevMgr.SetRevisionCounters, RevMgr.Commit). There's no error or exception; the PDM revision just won't write.
Any ideas what I'm doing wrong?
I have an API that is supposed to be setting the PDM vault revision counter, and runs without error, but does not actually write the new revision value.
Background: I'm trying to set revisions for a vault of legacy data where the rev is stored in the custom properties via external PDM and PLM systems, but the actual vault PDM rev isn't set.
Code details: I'm pulling the correct legacy revision from the custom properties via Document Manager API (plus some additional user input when there are 2+ unique revs saved on the same file ), and reading the information for the revision counter name and value through the PDM API. A lot of the code in question is borrowed heavily from the "Set Initial Revision" Help example:http://help.solidworks.com/2020/english ... _VBNET.htm.
This seems to be the problem area:
Code: Select all
If Not currentRev = newRev Then
MsgBox("The PDM Revision, ( " & currentRev & " ), will be set to the file property revision, ( " & newRev & " ).")
Dim RevCounters(0) As EdmRevCounter 'Assign the name of the revision counter
RevCounters(0).mbsComponentName = revVarName
Dim RevInt As Long
RevInt = Asc(newRev.ToUpper()) - Asc("A") + 1 ' Assign the New revision counter value to the value stored in the Revision card variable converted to an integer
RevCounters(0).mlCounter = RevInt
RevMgr.IncrementRevision(pdmFile.ID)
Debug.Print("After incrementing, currentRev is :" & pdmFile.CurrentRevision)
RevMgr.SetRevisionCounters(pdmFile.ID, RevCounters) 'Set the revision counter to the new values
Debug.Print("RevCounter value is " & RevCounters(0).mlCounter)
Debug.Print("Rev alpha value will be " & Chr(RevCounters(0).mlCounter))
Dim RevErrors() As EdmRevError = {}
RevMgr.Commit("Set starting revision for legacy file.", RevErrors) 'Save the new values to the database
Debug.Print("After committing, currentRev is :" & pdmFile.CurrentRevision)
Else
MsgBox("The PDM revision (" & currentRev & " ) already matches the cprop rev ( " & newRev & " )!")
Exit Sub
End If
Any ideas what I'm doing wrong?