Vault Customization

Vault Customization

Reply
Valued Contributor kbo
Valued Contributor
kbo
Posts: 84
Registered: ‎08-18-2010
Message 1 of 3 (483 Views)
Accepted Solution

inventor vault browser refresh / update? after changing lifecycle states.

483 Views, 2 Replies
06-25-2013 03:43 PM

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

 

ADN Support Specialist
wayne.brill
Posts: 198
Registered: ‎08-25-2004
Message 2 of 3 (456 Views)

Re: inventor vault browser refresh / update? after changing lifecycle states.

07-02-2013 03:26 PM in reply to: kbo

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



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Valued Contributor kbo
Valued Contributor
kbo
Posts: 84
Registered: ‎08-18-2010
Message 3 of 3 (436 Views)

Re: inventor vault browser refresh / update? after changing lifecycle states.

07-15-2013 06:07 AM in reply to: wayne.brill

Thank's

 

The "VaultRefresh" was what i was looking for.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.