Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Look in a specific folder

12 REPLIES 12
Reply
Message 1 of 13
CadUser46
1684 Views, 12 Replies

Look in a specific folder

How to tell my code to look in a specific folder?

 

Dim folder As VDF.Vault.Currency.Entities.Folder = conn.WebServiceManager.DocumentService.GetFolderByPath("$/Designs/sub1/sub2/sub3/")

 

No folder.name or folder.path?

 

Also I see many instances where the SDK says specify a folderID.  Can someone enlighten me as to what it actually wants? 


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
12 REPLIES 12
Message 2 of 13
wayne.brill
in reply to: CadUser46

Hi,

 

What function are you using that needs a folder? Does it take a Folder Id?  If so, is using the Id property of the Folder not a solution?

 

This is usually the approach I see, get the folder using something like are you are and then using the ID property.  (or something FileIteration.FolderId)

 

Thanks,

Wayne

 

 

 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 3 of 13
CadUser46
in reply to: wayne.brill

Hi Wayne.

 

I am looking at different approaches to a larger problem and trying to fumble my way through the SDK.

 

In the samples there is one that passes in the folder root object.  I dont want to do this so was hoping to loop through (get) files in a sub folder.

 

Please spell it out for me if you could in vb preferably.

 


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
Message 4 of 13
psaarloos
in reply to: CadUser46

Hi,

 

The VaultList sample from the SDK might get you started. The 'PrintFilesInFolder' procedure in this sample is recursive.

 

 Private Sub PrintFilesInFolder(parentFolder As VDF.Vault.Currency.Entities.Folder, connection As VDF.Vault.Currency.Connections.Connection)
        ' get all the Files in the current Folder.
        Dim childFiles As File() = connection.WebServiceManager.DocumentService.GetLatestFilesByFolderId(parentFolder.Id, False)

        ' print out any Files we find.
        If childFiles IsNot Nothing AndAlso childFiles.Any() Then
            For Each file As File In childFiles
                ' print the full path, which is Folder name + File name.
                Me.m_listBox.Items.Add((Convert.ToString(parentFolder.FullName) & "/") + file.Name)
            Next
        End If

        ' check for any sub Folders.
        Dim folders As IEnumerable(Of VDF.Vault.Currency.Entities.Folder) = connection.FolderManager.GetChildFolders(parentFolder, False, False)
        If folders IsNot Nothing AndAlso folders.Any() Then
            For Each folder As VDF.Vault.Currency.Entities.Folder In folders
                ' recursively print the files in each sub-Folder
                PrintFilesInFolder(folder, connection)
            Next
        End If
    End Sub

 

Hope this helps.

Regards,
Pim Saarloos
Product Manager
If my post answers your question, please click the "Accept as Solution" button. Kudos are much appreciated!
Message 5 of 13
CadUser46
in reply to: psaarloos

It still leaves me with the same problem.  How do i pass in the folder i'm interested in?  What does a folderID look like?


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
Message 6 of 13
psaarloos
in reply to: CadUser46

Hi,

 

Is the folder you're interested in a Vault folder/path or a local folder/path? What are you trying to achieve? A folder object has some properties. One of them is the Id property, which is a long value (ex: 541). 

Regards,
Pim Saarloos
Product Manager
If my post answers your question, please click the "Accept as Solution" button. Kudos are much appreciated!
Message 7 of 13
gmeinders
in reply to: psaarloos

I have the same question as OP. Actually I have 3 questions:

1. Where is the API documentation? As in: all of it? Not just the examples or very general VDF explanations?
2. How to set the VDF.Vault.Currency.Entities.Folder object to a folder of your chosing? How do I set that object to point to Vault folder "$/Content center/Give/Me/My/Folder/"?
3. Can this forum be made compatible with Firefox please? I keep getting the "Your post has been changed because invalid HTML was found in the message body. The invalid HTML has been removed. Please review the message and submit the message when you are satisfied." error when trying to post something in Firefox.
Message 8 of 13
connor.ferguson
in reply to: CadUser46

I think the issue is the VDF folder is an Entities.Folder object but the document service method gives you back a webservices.folder object. Both reference the same Vault folder with the same ID but have different methods depending on what you want to do with the Folder. Entities are used through the VaultConnection Object. The below gets a webservices.folder and uses the ID of that to get the Entities.Folder (In VB.net)

 

      Dim vaultWebServicesFolder As Autodesk.Connectivity.WebServices.Folder =         ServiceManager.DocumentService.GetFolderByPath("$/Designs")
      Dim vaultEntitiesFolder As Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.Folder = VaultConnection.FolderManager.GetFoldersByIds({vaultWebServicesFolder.Id}).First.Value

Message 9 of 13

Looking for help on this subject if the post is still open.  I am also trying the same scenario.  Passing a specific folder to the PrintFilesInFolder sub that comes with the SDK.  But having trouble.  I have included a stripped down version of my code.  Any help would be greatly appreciated.  The two things I am struggling with are noted in red.  So close yet so far away.

 

 

Message 10 of 13

Yes nearly there! Its just understanding when working with the connection object, its an entity.Folder but when working with the WebServiceManager is a Webservices.Folder. The below will work without adding anymore references.

 

Imports System.Windows.Forms
Imports Autodesk.Connectivity.WebServices
Imports Autodesk.Connectivity.WebServicesTools
Imports VDF = Autodesk.DataManagement.Client.Framework

Module ConsoleApp
    Sub Main()
        Dim results As VDF.Vault.Results.LogInResult = VDF.Vault.Library.ConnectionManager.LogIn("localhost", "Vault", "Administrator", "", VDF.Vault.Currency.Connections.AuthenticationFlags.Standard, Nothing)

        If Not results.Success Then
            Return
        End If

        Dim connection1 As VDF.Vault.Currency.Connections.Connection = results.Connection
        Try
            Dim Folder1 As Folder = connection1.WebServiceManager.DocumentService.GetFolderByPath("$/Work Folder/Standard Product")
            'Errors here, I think I am missing a reference, maybe webservicestools which didn’t come with the SDK?
            'Should be a webservices folder (Autodesk.Connectivity.WebServices.Folder) not an entitites folder, 
            Dim vaultEntitiesFolder As Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.Folder = connection1.FolderManager.GetFoldersByIds({Folder1.Id}).First.Value

            PrintFilesInFolder(Folder1, connection1.WebServiceManager)
        Catch ex As Exception
            MessageBox.Show(ex.ToString(), "Error")
            Return
        End Try
    End Sub

    Private Sub PrintFilesInFolder(Folder1 As Folder, ServiceManager As WebServiceManager)
        'Same as above

        Dim FolderFiles As File() = ServiceManager.DocumentService.GetLatestFilesByFolderId(Folder1.Id, False)
        For Each FolderFile As File In FolderFiles

            Console.WriteLine(FolderFile.Name)

        Next


    End Sub


End Module
Message 11 of 13

Thank you!  This definitely got me farther but the servicemanager as webservicemanager is not working.  Is it part of the "Autodesk.Connectivity.WebServicesTools"?  I don't have the reference for that and it wasn't included in the SDK.  Again, thank you.  I really appreciate the help.

Message 12 of 13

Imports Autodesk.Connectivity.WebServicesTools

Its part of the webservices reference, you should be able to add the line below to the imports at the top of your code page.  A little tip, if you just type it anyway and hover over it, Visual studio will give you suggestions to resolve and it will add the import for you.

 

 

 

Message 13 of 13

* line above

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report