“文件”、“文件夹”和“自定义对象”实体的 XAML 文件都是预先配置的。不过,在此目录中可以创建更多 XAML 文件,并且可以针对同一实体显示不同的 XAML 文件。
若要针对同一实体显示不同的对话框,请创建一个包含以下目录中的内容的 PowerShell 文件:%programdata%\Autodesk\Vault [版本]\Extensions\DataStandard\Vault\addinVault\Menus。
自定义 XAML 文件的示例
$vaultContext.ForceRefresh = $true
$currentSelected = $vaultContext.CurrentSelectionSet[0]
$folderid = $currentSelected.Id
#if selected object is of type 'FILE' then use $vaultContext.NavSelectionSet[0].Id,
#it will give you back the folder Id where this file is located
if ($currentselected.typeid.entityclassid--eq-"file")
{
$folderid = $vaultContext.NavSelectionSet[0].Id
}
$xamlFile = New-Object CreateObject.WPF.XamlFile "MyOwnXaml", "C:\ProgramData\Autodesk\Vault [edition]\Extensions\DataStandard\Vault\Configuration\myfile.xaml"
$dialog = $dsCommands.GetCreateDialog($folderid)
$dialog.XamlFile = $xamlFile
#new file can be found in $dialog.CurrentFile
$result = $dialog.Execute()
$dsDiag.Trace($result)
if ($result)
{
$folder = $vault.DocumentService.GetFolderById($folderid)
$path=$folder.FullName+"/"+$dialog.CurrentFile.Name
$selectionId = [Autodesk.Connectivity.Explorer.Extensibility.SelectionTypeId]::File
$location = New-Object Autodesk.Connectivity.Explorer.Extensibility.LocationContext $selectionId, $path
#$dsDiag.Inspect()
$vaultContext.GoToLocation = $location
}对话框加载(通过 $dialog.Execute())后,可以使用 Data Standard 函数对其进行管理。有关如何执行上述示例中的代码的详细信息,请参见“菜单项”。