- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I am still very new in customizing and just can't find the solution to my problem.
Currently I am trying to create a folder structure according to a template via VDS. Have already read some posts but it does not work yet.
My CreateFolder.ps1
$folderId=$vaultContext.CurrentSelectionSet[0].Id
$vaultContext.ForceRefresh = $true
$dialog = $dsCommands.GetCreateFolderDialog($folderId)
#override the default dialog file assigned
$xamlFile = New-Object CreateObject.WPF.XamlFile "ADSK.QS.Folder.xaml", "C:\ProgramData\Autodesk\Vault 2021\Extensions\DataStandard\Vault.Custom\Configuration\ADSK.QS.Folder.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
#recursively add subfolders to new folders that are not base category folders
$UIString = mGetUIStrings
$NewFolder = $vault.DocumentService.GetFolderByPath($path)
if($NewFolder.Cat.Catname -eq $UIString["CAT6"])
{
#the new folder is the targetfolder to create subfolders, the source folder is the template to be used
$TempFolderName = "$/00_Administration/00_ProjektStruktur/Kunde/Standort" + $NewFolder.Cat.Catname
$tempFolder = $vault.DocumentService.GetFolderByPath($TempFolderName)
If($tempFolder){ mRecursivelyCreateFolders -targetFolder $NewFolder -sourceFolder $tempFolder}
}
$selectionId = [Autodesk.Connectivity.Explorer.Extensibility.SelectionTypeId]::Folder
$location = New-Object Autodesk.Connectivity.Explorer.Extensibility.LocationContext $selectionId, $path
$vaultContext.GoToLocation = $location
}
Library.ps1
function mRecursivelyCreateFolders($sourceFolder, $targetFolder)
{
If(-not $Global:FldPropDefs){
$Global:FldPropDefs = $vault.PropertyService.GetPropertyDefinitionsByEntityClassId("FLDR")
$Global:FldPropDefIds = @()
$Global:FldPropDefs| ForEach-Object {
If($_.IsSys -eq $false)
{
$Global:FldPropDefIds += $_.Id
}
}
}
$sourceSubFolders = $vault.DocumentService.GetFoldersByParentId($sourceFolder.Id,$false)
$mFldIdsArray = @() #collect the level's folder(s) Id(s)
$propInstParamArrayArray = @()
foreach ($folder in $sourceSubFolders) {
$mSourceFldrProps = $vault.PropertyService.GetProperties("FLDR", @($folder.id) , $Global:FldPropDefIds)
$mSourceUdpInstArray = @()
$mSourceUdpInstArray += $mSourceFldrProps | Where-Object { $Global:FldPropDefIds -contains $_.PropDefId}
$newTargetSubFolder = $vault.DocumentServiceExtensions.AddFolderWithCategory($folder.Name, $targetFolder.Id, $folder.IsLibrary, $folder.Cat.CatId)
$mFldIdsArray += $newTargetSubFolder.Id
$propInstParamArray = New-Object Autodesk.Connectivity.WebServices.PropInstParamArray #collect the folder's property instance arrays
Foreach($Inst in $mSourceUdpInstArray)
{
$propInstParam = New-Object Autodesk.Connectivity.WebServices.PropInstParam
$propInstParam.PropDefId = $Inst.PropDefId
$propInstParam.Val = $Inst.Val
$propInstParamArray.Items += $propInstParam
}
$propInstParamArrayArray += $propInstParamArray
mrecursivelyCreateFolders -targetFolder $newTargetSubFolder -sourceFolder $folder
#returning to the initial level we can update the level folder's properties
}
Try{
$vault.DocumentServiceExtensions.UpdateFolderProperties($mFldIdsArray, $propInstParamArrayArray)
}
catch {}
} #end function mRecursivelyCreateFolders
In dataStandardVaultlob.txt I get an error.
2021-05-06 22:06:41,655 [1] ERROR CreateObject.WPF.DSNumSchemeCtrl - DSNumSchemeCtrl_ValueChanged:System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei Common.NumberingScheme.NumSchmService.GetNumSchmFields(NumSchm numSchm)
bei CreateObject.WPF.DSNumSchemeCtrl.DSNumSchemeCtrl_ValueChanged(Object sender, RoutedPropertyChangedEventArgs`1 e)
2021-05-06 22:06:46,497 [1] ERROR CreateObject.WPF.DSNumSchemeCtrl - Invalid numschm value. Only object of Type NumSchm are accepted as value.
Can someone give me a hint what i am doing wrong?
Solved! Go to Solution.
