範例 - 載入不同的「Data Standard」對話方塊

檔案、資料夾和自訂物件圖元的 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 功能對其進行管理。若要取得有關如何執行上述範例之程式碼的更多資訊,請參閱〈功能表項目〉。