Vault Data Standard 2018 Folder Structure

Vault Data Standard 2018 Folder Structure

dariuszm
Advocate Advocate
1,140 Views
2 Replies
Message 1 of 3

Vault Data Standard 2018 Folder Structure

dariuszm
Advocate
Advocate

Hello,

 

1. I'm trying to create option with Vault Data Standard to create a folder structure setected from template file (xaml). I found a solution on this page:

 

https://blog.coolorange.com/2014/10/17/create-folder-tree-from-a-template/

 

This Code work good but it need one additonal property ("Template").

 

My question is that can VDS do same without New property?

 

There is my modified code for create folder structure with one new property:

 

function recursivelyCreateFolders($childFolders, $newFolder,$folderCategories)
{
	if($childFolders -eq $null) { return }
	$dsDiag.Trace(">> recursivelyCreateFolders($childFolders, $($newFolder.FullName))")
	foreach ($folder in $childFolders) {
		$newSubFolder = $vault.DocumentServiceExtensions.AddFolderWithCategory($folder.Name, $newFolder.Id, $false, $folderCategories[$folder.Category])
		recursivelyCreateFolders -childFolders $folder.ChildNodes -newFolder $newSubFolder -folderCategories $folderCategories
	}
	$dsDiag.Trace("<< recursivelyCreateFolders")
}


$folderId=$vaultContext.CurrentSelectionSet[0].Id
$vaultContext.ForceRefresh = $true
$dialog = $dsCommands.GetCreateFolderDialog($folderId)
$xamlFile = New-Object CreateObject.WPF.XamlFile "Device.xaml", "%ProgramData%\Autodesk\Vault 2018\Extensions\DataStandard\Vault\Configuration\Device.xaml"
$dialog.XamlFile = $xamlFile


$result = $dialog.Execute()
$dsDiag.Trace($result)

if($result)
{
	#new folder can be found in $dialog.CurrentFolder
	$folder = $vault.DocumentService.GetFolderById($folderId)
	$path=$folder.FullName+"/"+$dialog.CurrentFolder.Name




	$newFolder = $vault.DocumentService.GetFolderByPath($path)

#Is there property insert?
$template = $dialog.ViewModel.Prop["Template"].Value if($template -ne "") { [xml]$xml = Get-Content "C:\ProgramData\Autodesk\Vault 2018\Extensions\DataStandard\Vault\Configuration\DeviceTemplates.xml" $folderTree = Select-Xml -Xml $xml -XPath "//Template[@Name='$template']" $folderCats = $vault.CategoryService.GetCategoriesByEntityClassId("FLDR",$true) $fc = @{} $folderCats | ForEach-Object { $fc[$_.Name]=$_.Id} recursivelyCreateFolders -childFolders $folderTree.Node.ChildNodes -newFolder $newFolder -folderCategories $fc } [System.Reflection.Assembly]::LoadFrom("C:\Program Files\Autodesk\Vault Professional 2018\Explorer\Autodesk.Connectivity.Explorer.Extensibility.dll") $selectionId = [Autodesk.Connectivity.Explorer.Extensibility.SelectionTypeId]::Folder $location = New-Object Autodesk.Connectivity.Explorer.Extensibility.LocationContext $selectionId, $path $vaultContext.GoToLocation = $location }

 

 

2. One more question about VDS is that, can I display some (not all) folder properties dependent what User choose in Create Folder Dialog Box of One property list [One property with multiple selection]. For example User choose [TYPE] is [Device_1] then on right show just [Device_1_property 1] and [Device_1_property 2], if User choose [TYPE] is [Device_2] then on right show [Device_2_property 1] and [Device_2_property 2]. Best if I can use to this a template file. Is that posible? 

0 Likes
1,141 Views
2 Replies
Replies (2)
Message 2 of 3

wangdu
Collaborator
Collaborator

Hi,

 

As for your question #1, you can do it without creating a new property. If I have got it correctly then the only use of the property is to hold the user selected value.

  • One option that comes to mind is to store in a variable and use that in the OnPostCloseDialog function.  You will need to subscribe to the selectionchanged event of the combobox from the powershell script probably inside the InitializeWindow function of Default.ps1. In case if the variable isn't accessible, then you can see if i works by declaring it as global variable.
  • If the above doesn't work at all, then you might think about storing the value in a temporary file and then read it back in the OnPostCloseDialog function. But I hope the above solution might work.

As for the question #2, from what I understand, it looks like you could be able to do it using DataGrid. Similar to how the dynamic properties is working (displaying proeperties depending on the selected category), you want to have a combobox's selected item to drive the list of properties displayed in the dialog. The only difference is that the selected item of the combobox is used as prefix to filter the result of the properties in the dialog. So, therefore, i suggest you to give a look at WPF DataGrid, along with CollectionViewSource for filtering which you might have to do it through code.

 

Hope it helps!

 

Wangdu

 

coolOrange

www.coolOrange.com

0 Likes
Message 3 of 3

Anonymous
Not applicable

Hi all,

 

I need some help about copying folder structure template with different categories of folder.

I created a template folder ( Project Folder Template) which includes different files and subfolders.

These subfolders have different cathegories.

In the picture you can observe them just like the color that they have.

 

I modified the Default.ps1 file as below, but now the function copy folder and subfolder only with "project Folder" CatName.

 

How can I add other category folders? and the files included?

 

Many thanks

Gianpaolo

 

 

 

function GetListOfVaultProjects()
{
     $dsDiag.Trace(">> GetListOfVaultProjects")
     $designsFolder = $vault.DocumentService.GetFolderByPath("$/Templates")
     $subFolders = $vault.DocumentService.GetFoldersByParentId($designsFolder.Id,$false)
     $projectFolders = $subFolders | Where-Object { $_.Cat.CatName -eq "Project Folder" }
  $listOfProjects = $projectFolders | ForEach-Object { $_.FullName }
     $dsDiag.Trace("<< GetListOfVaultProjects")
     return @($listOfProjects)
}

 

 

0 Likes