I use the attached code to change lifecycle states on files inside vault, based on the assembly bom open in inventor.
All works fine, but i manuel have to click the vault browser refresh button inside inventor to update the browser in inventor, is there anyway to do this via the API? Maybe this is a inventor customization question.
Please help!
Regards kent boettger
Private Sub CheckLifeCycleStateOnFiles(ByVal strVaultFilePath1WithoutFileName As String, ByVal mVaultfilename As String, ByVal strLocalFilePathWithoutFileName As String, ByVal strLocalFilePathWithFileName As String, ByVal DocSrv As DocumentService, ByVal DocSrvExt As DocumentServiceExtensions) 'Get hostname for FileCheckOut Dim strHostName As String strHostName = System.Net.Dns.GetHostName() 'Set the VaultFileName Dim oVaultFileName As String = mVaultfilename 'Set the VaultFileFolder Dim oVaultFileFolder As Folder = DocSrv.GetFolderByPath(strVaultFilePath1WithoutFileName) 'Loop because fileID changes when changing LifeCycleState For i As Integer = 0 To 2 Dim oVaultFiles As Autodesk.Connectivity.WebServices.File() = DocSrv.GetLatestFilesByFolderId(oVaultFileFolder.Id, False) For Each oVaultFile As Autodesk.Connectivity.WebServices.File In oVaultFiles If oVaultFile.Name = oVaultFileName Then Try 'Get FileID Dim ThisFileID As Long = oVaultFile.Id 'Get FolderID Dim ThisFileFolderID As Long = oVaultFileFolder.Id 'Get file master ID Dim ThisFileMasterID() As Long = New Long() {DocSrv.GetFileById(oVaultFile.Id).MasterId} 'Create array of LyfecycleStates Dim ThisFileLifeCycleState() As Long = New Long() {24, 25, 26, 27, 28} 'Lifecycle Definitions 'Name : Monsun Basic Release Process = 6 'Lifecycle States 'Work in Progress = LifecyclestateID 24 'For Review = LifecyclestateID 25 'Released = LifecyclestateID 26 'Obsolete = LifecyclestateID 27 'Ready for deletion = LifecyclestateID 28 Dim ThisFileLifecycleStateName As String = DocSrv.GetFileById(ThisFileID).FileLfCyc.LfCycStateName Dim ThisFileLifeCyclestateID As Long = DocSrv.GetFileById(ThisFileID).FileLfCyc.LfCycStateId Dim ThisFileLifeCycledefinitionID As Long = DocSrv.GetFileById(ThisFileID).FileLfCyc.LfCycDefId 'MsgBox("Filnavn : " & oVaultFile.Name & " FileID : " & ThisFileID & " FileMasterID : " & ThisFileMasterID(0) & " StatusNavn : " & ThisFileLifecycleStateName & " Status : " & ThisFileLifeCyclestateID) ' check if the file has status released If ThisFileLifeCyclestateID = "26" Then Try 'set the file to lifecycle state "for review" to prevent revision number change on checkout. DocSrvExt.UpdateFileLifeCycleStates(New Long() {ThisFileMasterID(0)}, New Long() {ThisFileLifeCycleState(1)}, "Ax2009 Properties sync.") Catch ex As Exception MsgBox(ex.Message & " Error change from, Released to For review") End Try End If 'check if the file has status "For Review" If ThisFileLifeCyclestateID = "25" Then Try 'set the file to lifecycle state "Work in Progress" DocSrvExt.UpdateFileLifeCycleStates(New Long() {ThisFileMasterID(0)}, New Long() {ThisFileLifeCycleState(0)}, "Ax2009 Properties sync.") Catch ex As Exception MsgBox(ex.Message & " Error change from, For review to Work in progress") End Try End If 'check if the file has status "Work in Progress" If ThisFileLifeCyclestateID = "24" Then Try 'check if the file is checked out if not check out the file If oVaultFile.CheckedOut = False Then Dim fileData As Byte() = Nothing oVaultFile = DocSrv.CheckoutFile(ThisFileFolderID, ThisFileID, CheckoutFileOptions.Master, strHostName, strLocalFilePathWithFileName, "Ax2009 Properties sync.", False, False, fileData) Dim mfilepath As String = (strLocalFilePathWithoutFileName & oVaultFileName) SetFileReadAccess(oVaultFile, mfilepath) End If Catch ex As Exception MsgBox(ex.Message & "Error checking out file from Work i progress") End Try End If 'check if the file has status "Obsolete" If ThisFileLifeCyclestateID = "27" Then MsgBox("The file " & strLocalFilePathWithFileName & " is set to, Obsolete - Replace the file with the new one") End If 'check if the file has status "Ready for Deletion" If ThisFileLifeCyclestateID = "28" Then MsgBox("The file " & strLocalFilePathWithFileName & " is set to, ready for deletion") End If Catch ex As Exception MsgBox(ex.Message & " Error in change lifecycle state") End Try End If Next Next End Sub 'Sets the read-only value of a file. Sub SetFileReadAccess(ByVal LocalVaultfile As Autodesk.Connectivity.WebServices.File, ByVal LocalVaultFilePath As String) ', ByVal SetReadOnly As Boolean'ByVal LocalPath As String, Try Dim info As System.IO.FileInfo = New FileInfo(LocalVaultFilePath) info.IsReadOnly = False info.CreationTime = LocalVaultfile.CreateDate Catch ex As Exception MsgBox(ex.Message) End Try End Sub
Solved! Go to Solution.
Solved by wayne.brill. Go to Solution.
Hi Kbo,
Try using the VaultRefresh command. You can run a command from the Inventor API using the Execute function.
Here is a VBA example:
Public Sub sendVaultCommand()
ThisApplication.CommandManager.ControlDefinitions.Item("VaultRefresh").Execute
End Sub
You can get all commands that Inventor supports (including the commands added by the Vault AddIn) by using code similar to this. (it is from the Inventor help file)
Sub PrintCommandNames()
Dim oControlDefs As ControlDefinitions
Set oControlDefs = ThisApplication.CommandManager.ControlDefinitions
Dim oControlDef As ControlDefinition
Open "C:\temp\CommandNames.txt" For Output As #1
Print #1, Tab(10); "Command Name"; Tab(75); "Description"; vbNewLine
For Each oControlDef In oControlDefs
Print #1, oControlDef.InternalName; Tab(55); oControlDef.DescriptionText
Next
Close #1
End Sub
The Vault AddIns such as the Inventor AddIn do not have any customization support.
Thanks,
Wayne