<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Finding the Associated Files of an assembly with the Vault API in Vault Customization Forum</title>
    <link>https://forums.autodesk.com/t5/vault-customization-forum/finding-the-associated-files-of-an-assembly-with-the-vault-api/m-p/8252924#M5996</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ParFileId and CldFileId properties&amp;nbsp;are file ids within this FileAssocLite class that you need to use&amp;nbsp;depending on your settings passed in the parameter. In your case, the CldFileId property probably is the correct one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wangdu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;coolOrange&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.coolOrange.com" target="_blank"&gt;www.coolOrange.com&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Sep 2018 14:13:40 GMT</pubDate>
    <dc:creator>wangdu</dc:creator>
    <dc:date>2018-09-07T14:13:40Z</dc:date>
    <item>
      <title>Finding the Associated Files of an assembly with the Vault API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/finding-the-associated-files-of-an-assembly-with-the-vault-api/m-p/8251319#M5993</link>
      <description>&lt;P&gt;I'm fairly new to programming, so bear with me...&lt;BR /&gt;&lt;BR /&gt;I'm trying to to make a section of code that will find a file by searching for an&amp;nbsp;assembly part number. Once the file is found, I want to return all the associated file names (the sub-assemblies and parts) like the "uses" tool in vault. I'm trying to use&amp;nbsp;GetFileAssociationLites to&amp;nbsp;find the related file IDs and then&amp;nbsp;GetFilesByIds to return an array of all the files which I can then get the names of, but something is wrong.&lt;BR /&gt;&lt;BR /&gt;It is giving me an error at the GetFilesByIds line, which I think is related to the output from GetFileAssociationLites, but I can't figure out the issue. Everything else seems to be working.&lt;BR /&gt;&lt;BR /&gt;Any help is really appreciated... thanks&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;        'part number search term (hardcoded for example)
        Dim searchterm As String
        searchterm = "5-AIIDRI12TA-KT87SB"

        'set up search
        Dim filePropDefs As PropDef() = connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
        Dim projectPropDef As PropDef = filePropDefs.[Single](Function(n) n.SysName = "PartNumber")
        Dim condition As New SrchCond() With {.PropDefId = projectPropDef.Id, .PropTyp = PropertySearchType.SingleProperty, .SrchOper = 3, .SrchRule = SearchRuleType.Must, .SrchTxt = searchterm}
        Dim bookmark As String = String.Empty
        Dim status As SrchStatus = Nothing

        'do the search and return the file(s) with the matching part number
        Dim files As File() = connection.WebServiceManager.DocumentService.FindFilesBySearchConditions(New SrchCond() {condition}, Nothing, Nothing, True, True, bookmark, status)

        'setup file relationship settings (for use in the loop below)
        Dim myFileRelationshipSettings As VDF.Vault.Settings.FileRelationshipGatheringSettings
        myFileRelationshipSettings = New VDF.Vault.Settings.FileRelationshipGatheringSettings
        myFileRelationshipSettings.IncludeAttachments = False
        myFileRelationshipSettings.IncludeChildren = True
        myFileRelationshipSettings.IncludeParents = True
        myFileRelationshipSettings.IncludeRelatedDocumentation = False

        'go through each file found with the search term
        If files IsNot Nothing AndAlso files.Any() Then
            For Each file As File In files

                'get the file ID from the file
                Dim fileid As Long
                fileid = file.Id

                'use this file ID to find the associated file IDs and store in an array
                Dim relatedfileids As Array
                relatedfileids = connection.FileManager.GetFileAssociationLites(New Long() {fileid}, myFileRelationshipSettings)

                'use the related file IDs to find each associated file and store in an array
                Dim relatedfiles As Array
                relatedfiles = connection.WebServiceManager.DocumentService.GetFilesByIds(relatedfileids) '********** This line is giving me the error **********

                '(testing only) send each associated file name to a message box to check what's going on
                Dim i As Long
                For i = 0 To UBound(relatedfiles)
                    MsgBox(relatedfiles(i).name)
                Next

            Next
        End If&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 22:53:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/finding-the-associated-files-of-an-assembly-with-the-vault-api/m-p/8251319#M5993</guid>
      <dc:creator>8013068</dc:creator>
      <dc:date>2018-09-06T22:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Associated Files of an assembly with the Vault API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/finding-the-associated-files-of-an-assembly-with-the-vault-api/m-p/8251818#M5994</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The FileManager.GetFileAssociationLites method&amp;nbsp;gives you back IEnumerable&amp;lt;FileAssocLite&amp;gt; and so you can't just pass them to the GetFilesByIds method. That would explain why you are getting the error on GetFilesByIds method.&lt;/P&gt;&lt;P&gt;As a side note, check the results and see if that's what you are expecting, otherwise the settings for IncludeParents might not be necessary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wangdu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;coolOrange&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.coolOrange.com" target="_blank"&gt;www.coolOrange.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 06:36:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/finding-the-associated-files-of-an-assembly-with-the-vault-api/m-p/8251818#M5994</guid>
      <dc:creator>wangdu</dc:creator>
      <dc:date>2018-09-07T06:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Associated Files of an assembly with the Vault API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/finding-the-associated-files-of-an-assembly-with-the-vault-api/m-p/8252729#M5995</link>
      <description>&lt;P&gt;Thank you, that's really helpful. For some reason, I thought GetFileAssociationLites returned an array of file IDs. Do you how I can use the IEnumerable&amp;lt;FileAssocLite&amp;gt; file to get the file Ids?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 13:19:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/finding-the-associated-files-of-an-assembly-with-the-vault-api/m-p/8252729#M5995</guid>
      <dc:creator>8013068</dc:creator>
      <dc:date>2018-09-07T13:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Associated Files of an assembly with the Vault API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/finding-the-associated-files-of-an-assembly-with-the-vault-api/m-p/8252924#M5996</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ParFileId and CldFileId properties&amp;nbsp;are file ids within this FileAssocLite class that you need to use&amp;nbsp;depending on your settings passed in the parameter. In your case, the CldFileId property probably is the correct one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wangdu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;coolOrange&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.coolOrange.com" target="_blank"&gt;www.coolOrange.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 14:13:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/finding-the-associated-files-of-an-assembly-with-the-vault-api/m-p/8252924#M5996</guid>
      <dc:creator>wangdu</dc:creator>
      <dc:date>2018-09-07T14:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Associated Files of an assembly with the Vault API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/finding-the-associated-files-of-an-assembly-with-the-vault-api/m-p/8253318#M5997</link>
      <description>&lt;P&gt;Thanks for the help. I've gotten some code to work. I'm sure it could be better, but here it is for anyone else struggling with this. Also, this was a good resource:&amp;nbsp;&lt;A href="http://adndevblog.typepad.com/manufacturing/2013/09/vault-2014-api-example-that-adds-a-file-and-associates-it-to-an-existing-file-in-the-vault.html" target="_blank"&gt;http://adndevblog.typepad.com/manufacturing/2013/09/vault-2014-api-example-that-adds-a-file-and-associates-it-to-an-existing-file-in-the-vault.html&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;        'setup file relationship settings (for use in the loop below)
        Dim myFileRelationshipSettings As VDF.Vault.Settings.FileRelationshipGatheringSettings
        myFileRelationshipSettings = New VDF.Vault.Settings.FileRelationshipGatheringSettings
        myFileRelationshipSettings.IncludeAttachments = False
        myFileRelationshipSettings.IncludeChildren = True
        myFileRelationshipSettings.IncludeParents = False
        myFileRelationshipSettings.IncludeRelatedDocumentation = False

        'go through each file found with the search term
        If files IsNot Nothing AndAlso files.Any() Then
            For Each file As File In files

                'get the file ID from the file
                Dim fileid As Long
                fileid = file.Id

                'find the file associations
                Dim relatedfileassoc = GV.connectionx.FileManager.GetFileAssociationLites(New Long() {fileid}, myFileRelationshipSettings)
                'GV.connectionx

                'go through each association
                Dim fileassoc As FileAssocLite
                For Each fileassoc In relatedfileassoc
                    'get the related files and show their names
                    Dim relatedfile As File
                    relatedfile = GV.connectionx.WebServiceManager.DocumentService.GetFileById(fileassoc.CldFileId)
                    MsgBox(relatedfile.Name)
                Next
            Next

        End If&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Sep 2018 16:17:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/finding-the-associated-files-of-an-assembly-with-the-vault-api/m-p/8253318#M5997</guid>
      <dc:creator>8013068</dc:creator>
      <dc:date>2018-09-07T16:17:01Z</dc:date>
    </item>
  </channel>
</rss>

