Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Richard.MM
in reply to: maxim.teleguz

Hi,

I am sending the code we are using and it works.

MsgBox outputs are written in Czech language.

 Public Sub GetWhereUsed(m_inventorApp_rr As Inventor.Application)
        m_inventorApp = m_inventorApp_rr
        m_inventorApp.Visible = True
        Dim oDoc As Inventor.Document
        oDoc = m_inventorApp.ActiveDocument

        If m_inventorApp.ActiveDocument.DocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject Then

            MessageBox.Show("Zdarec, máš otevřený výkres, akce bude přerušena", "Nespi!", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub

        End If

        Dim hledam As String = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) + System.IO.Path.GetExtension(oDoc.FullFileName)


        Dim results As VDF.Vault.Results.LogInResult = VDF.Vault.Library.ConnectionManager.LogIn("xxxxx", "yyyyy", "zzzzz", "wwwww",
                                                                                                 VDF.Vault.Currency.Connections.AuthenticationFlags.WindowsAuthentication,
                                                                                                 Nothing)




        If Not results.Success Then
            MsgBox("Připojení k Vaultu se nezdařilo")
        End If

          connection = results.Connection


        Dim Defss As PropDef() = connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("ITEM")
        

        Dim Prop As PropDef = Nothing

        For Each def As PropDef In Defss

            
            If def.DispName = "Revision" Then

                Prop = def

            End If

        Next def

        Dim searchCondition As SrchCond = New SrchCond()
        searchCondition.PropDefId = Prop.Id

        defs = connection.WebServiceManager.PropertyService.FindPropertyDefinitionsBySystemNames("FILE", {"ClientFileName"})

        srchCond.PropDefId = defs(0).Id
        srchCond.PropTyp = PropertySearchType.SingleProperty
        srchCond.SrchRule = SearchRuleType.Must
        srchCond.SrchOper = 3
        srchCond.SrchTxt = hledam
        SrcConds(0) = srchCond


        Try
            files = connection.WebServiceManager.DocumentService.FindFilesBySearchConditions(SrcConds,
                                                                                             Nothing,
                                                                                             Nothing,
                                                                                             True,
                                                                                             True,
                                                                                             bookmark,
                                                                                             searchStatus)
        Catch

            MsgBox("Nemohu ziskat soubor z Vaultu")

        End Try


        Dim assocArray2 As FileAssocArray() = Nothing
        For Each chci In files
            If chci.Name = hledam Then
                assocArray2 = connection.WebServiceManager.DocumentService.GetLatestFileAssociationsByMasterIds(New Long() {chci.MasterId},
                                                                                                                                        FileAssociationTypeEnum.All,
                                                                                                                                        True,
                                                                                                                                        FileAssociationTypeEnum.None,
                                                                                                                                        True,
                                                                                                                                        True,
                                                                                                                                        True,
                                                                                                                                        True)

            End If
        Next


        If assocArray2(0).FileAssocs Is Nothing Then
            MessageBox.Show("Nemohu najít žádný výkres, zřejmě to budš muset udělat ručně!")
            Return

        End If

      
        Dim vykresy(assocArray2(0).FileAssocs.Count) As String

        If Not assocArray2 Is Nothing Then

             For i = 0 To assocArray2(0).FileAssocs.Count - 1
             
                If assocArray2(0).FileAssocs(i).ParFile.Name.EndsWith("idw") Then

                    If Not assocArray2(0).FileAssocs(i).ParFile.Name Is Nothing Then
                        vykresy(i) = assocArray2(0).FileAssocs(i).ParFile.Name
                    End If

                End If


            Next
        Else

            MessageBox.Show("Nemohu najít žádný výkres.")
            Exit Sub

        End If


        Dim arr As New ArrayList

        For i As Integer = 0 To vykresy.Length - 1
            If Not arr.Contains(vykresy.GetValue(i)) Then
                arr.Add(vykresy.GetValue(i))
            End If
        Next

        vykresy = arr.ToArray(GetType(String))


        Me.Show()
        Dim prvni As Integer = 0
   
        For Each sr In vykresy
            prvni = prvni + 1


            If Not sr Is Nothing Then
                If prvni = 1 Then
                    Me.CheckedListBox1.Items.Add(sr, True)

                Else
                    Me.CheckedListBox1.Items.Add(sr, False)
                End If

            End If

        Next
        TextBox1.AppendText(System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) + ".idw")


    End Sub