Inventor Add-In that gets the status of a file opened from Vault

By Wayne Brill

You may want to get the status of a file that was opened from Vault. See this blog post for a discussion on a way to do this.

This Inventor 2016 AddIn example uses the EntityStatusImageInfo to get the status of the Inventor active document. The example is only getting the status of a part but could be enhanced to get other file types.  (The reason it is only working with parts is because the button is added to the "PMxPartFeatureCmdBar" command bar).

A form is used to display the image returned from this call.

EntityStatusImageInfo.GetImage()

The Graphics.DrawImage() of the Windows.Forms.PaintEventArgs passed into the Paint event for the form is used to show the image on the form.

image

 

Download the Inventor Add-In (Visual Studio 2013 project)

  Download Vault_Lab_10_Complete_AddIn_Add_To_Ribbon

 

Click this button the Add-In adds to the ribbon to run the code.

image

 

Here is the procedure that gets the vault connection, the name of the active document and then uses a FileIteration to get the status. The FileIteration object is returned by using the name of the document. (that code is not shown here).

 

Public Sub test_Vault()    Dim myConnection As VDF.Vault.Currency.Connections.Connection = Nothing    ' Get the Vault connection from     ' the Inventor Vault log in    myConnection =        Connectivity.Application.VaultBase.ConnectionManager.Instance.Connection()    If myConnection Is Nothing Then        System.Windows.Forms.MessageBox.Show _                            ("Unable to get Vault connection, logged into Vault?")        ' Debug.Print("Unable to get Vault connection")        Return    End If    Try        'Get the name of the Inventor active document        Dim strFullNameOfDoc As String =                              m_inventorApplication.ActiveDocument.FullFileName        Dim strFileName As String = System.IO.Path.GetFileName(strFullNameOfDoc)        Dim _FileIteration As VDF.Vault.Currency.Entities.FileIteration = Nothing        _FileIteration = getFileIteration(strFileName, myConnection)        If Not _FileIteration Is Nothing Then            Dim props As PropertyDefinitionDictionary =                myConnection.PropertyManager.GetPropertyDefinitions _                                 (VDF.Vault.Currency.Entities.EntityClassIds.Files, _                                    Nothing, PropertyDefinitionFilter.IncludeAll)            Dim statusProp As PropertyDefinition =                                       props(PropertyDefinitionIds.Client.VaultStatus)            Dim _status As EntityStatusImageInfo =                TryCast(myConnection.PropertyManager.GetPropertyValue _                          (_FileIteration, statusProp, Nothing), EntityStatusImageInfo)            System.Windows.Forms.MessageBox.Show _                                           ("Status =   " & _status.Status.ToString())            _img = _status.GetImage()            'Display a form that will show the Image            Dim _Frm As Form1 = New Form1            _Frm.Show()        Else            System.Windows.Forms.MessageBox.Show _                                     ("Did not find " & strFileName & " in the vault")        End If    Catch ex As System.Exception        System.Windows.Forms.MessageBox.Show("Error occurred:  " & ex.ToString())        'Debug.Print("unable to get Folder.  " & ex.ToString())    End TryEnd Sub

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading