Picking the right folder

A Data Standard fellow from Australia came across with a nice, simple request. Would it be possible to have in the Data Standard dialog 2 combo-boxes where the user can pick from Vault folders and according subfolders? The answer is of course yes, and it’s not that much of work.


Basically we have to do 3 things:

  1. Add in the Inventor.cfg and/or AutoCAD.cfg 2 fields in order to store the selected folders, and use the 2 fields in the PathDefinition
  2. Add 2 combo-boxes in the Inventor.xaml and/or AutoCAD.xaml
  3. Add some logic in the PowerShell script in order to get the list for folders from Vault and present them in the Data Standard dialog

Let’s start with the CFG file. I added 2 properties called VaultProject and VaultSubFolder, and I extended the PathDefinition with such properties. Here the code:

 <PropertyDefinition PropertyName="VaultProject" DataType="Text" RequiresValue="true" />
 <PropertyDefinition PropertyName="VaultSubFolder" DataType="Text" RequiresValue="true" />

Then I added the 2 combo-boxes into the XAML file. In order to position the combo-boxes at the right place, I had to add more rows in the parent Grid and reposition the existing controls. More information on XAML can be found here. And here is the code in the XAML.

<Grid Margin="25">
  <Label Content="Vault Projects" Grid.Column="0" Grid.Row="6" />
  <ComboBox Grid.Column="1" Grid.Row="6" ItemsSource="{Binding PsList[GetVaultProjects]}" SelectedValue="{Binding Prop[VaultProject].Value}" />
  <Label Content="Vault SubFolders" Grid.Column="0" Grid.Row="8" />
  <ComboBox Grid.Column="1" Grid.Row="8" SelectedValue="{Binding Prop[VaultSubFolder].Value}" x:Name="cmbVaultSubFolders"/>

As you can see, both combos have the SelectedValue bound to the according property, but only the first combo has an ItemsSource, bound to a PowerShell function.

Finally I wrote 2 little functions that pick folders from Vault. This is how my Default.ps1 looks like:

function InitializeWindow
    if($source.PropertyName -eq "Value") {

function GetVaultProjects
  $folder = $vault.DocumentService.GetFolderByPath("$/Designs")
  $folders = $vault.DocumentService.GetFoldersByParentId($folder.Id,$false)
  $projects = $folders | Where-Object { $_.Cat.CatName -eq "Project" }
  $names = @()
  $projects | ForEach-Object { $names += $_.Name }
  return $names

function GetVaultSubFolders
  $selectedProject = $Prop["VaultProject"].Value
  if($selectedProject -eq "") { return }
  $folder = $vault.DocumentService.GetFolderByPath("$/Designs/"+$selectedProject)
  $folders = $vault.DocumentService.GetFoldersByParentId($folder.Id,$false)
  $names = @()
  $folders | ForEach-Object { $names += $_.Name }
  $dSWindow.FindName("cmbVaultSubFolders").ItemsSource = $names

The first function gets all folders underneath $/Designs in category project. The second function gets the subfolders of the in the first combo selected folder, and sets the ItemsSource of the second combo programmatically. Now, as the second combo shall show different folders based on the folder selected in the first combo, as the user picks a folder in the first combo, the second function must be executed. That is why I added an event handler for the property VaultProject. So, every time the VaultProject changes, the function is executed and the second combo gets appropriate values.

And here is a zip file of the CAD folder, which contains CFG, XAML and PS1.

That’s it! Try it out and leave a comment if you like it, or want to know more!

This entry was posted in Data Standard. Bookmark the permalink.

7 Responses to Picking the right folder

  1. Rudaz says:

    Thank’s for this example.
    I have tested and it don’t work properly. The file name is not correct.
    The is False. The right value is {Prop[DocNumber].Value}.
    Sory for my English…. :)



  2. Rudaz says:

    And another thing,
    What happens when there will be more subfolders. For example 5-10


  3. Thomas Sperfeld says:

    I try to convert this code for Data Standard 2015 R2, but I dont know really how.
    Plase can help me someone!


  4. Volkan ARI says:


    I just tried it but combo boxes came empty. What could be the possible cause? Here is the screenshot;

    Here is my folder structure in Vault;

    Am I missing a setting?



    P.S. I’m using Vault Professional 2015

    • Volkan ARI says:


      I’m sorry, it’s my mistake. I copied the “Default.ps1” file to “C:\ProgramData\Autodesk\Vault 2015\Extensions\DataStandard\CAD\addins” and it worked like a charm.

      Thank you very much for the post by the way. :)


  5. Hi,

    I have the same Problem with empty boxes.
    I copied the Deafailt.ps1 file to C:\ProgramData\Autodesk\Vault 2015\Extensions\DataStandard\CAD\addins and they are still empty.
    What’s wrong?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s