Skip to content

Instantly share code, notes, and snippets.

@slydlake
Created November 25, 2020 13:28
Show Gist options
  • Save slydlake/9a1bb58bc77aec3889ed3db1d5b8a614 to your computer and use it in GitHub Desktop.
Save slydlake/9a1bb58bc77aec3889ed3db1d5b8a614 to your computer and use it in GitHub Desktop.
[VDS Open URL] #VDS #powershell
<?xml version="1.0" encoding="utf-8"?>
<!--
Label: Label string for the command, must be quoted
Description: Description text for the menucommand. Must be quoted
Hint: Hint string, must be quoted
PSFile: Name of the *ps1 file that contains the powershell script to execute when the menu command is invoked, value must be quoted.
Image: Name of a bitmap file that contains the image for the menu command. Image should be 16x16 or 32x32, value must be quoted.
ToolbarPaintStyle: Controls how the item is drawn on toolbars, values are Text, Glyph, TextAndGlyph
NavigationTypes: comma separated list of entities for which this command should be active. Values are Bom, ChangeOrder, File, FileVersion, Folder, Item, Other
MultiSelectEnabled: If true, command is active for multiple selections, can be true or false
-->
<mymenu>
<MenuItem>
<NewTask Label="$UIString[MNU22]" Description="$UIString[MNU17]" Hint="$UIString[MNU18]"
PSFile="CreateCustomObject.ps1" Image="NewCustomObject.ico" ToolbarPaintStyle="TextAndGlyph"
NavigationTypes="Task" MultiSelectEnabled="False" />
<EditTask Label="$UIString[MNU21]" Description="$UIString[MNU19]" Hint="$UIString[MNU20]"
PSFile="EditCustomObject.ps1" Image="EditCustomObject.ico" ToolbarPaintStyle="TextAndGlyph"
NavigationTypes="Task" MultiSelectEnabled="False" />
<NewFile Label="$UIString[MNU1]" Description="$UIString[MNU11]" Hint="$UIString[MNU7]" PSFile="CreateFile.ps1"
Image="NewStandardFile.ico" ToolbarPaintStyle="TextAndGlyph" NavigationTypes="File,Folder"
MultiSelectEnabled="False" />
<EditFile Label="$UIString[MNU2]" Description="$UIString[MNU12]" Hint="$UIString[MNU8]" PSFile="EditFile.ps1"
Image="EditFileDatasheet.ico" ToolbarPaintStyle="TextAndGlyph" NavigationTypes="File"
MultiSelectEnabled="False" />
<NewFolder Label="$UIString[MNU3]" Description="$UIString[MNU13]" Hint="$UIString[MNU9]" PSFile="CreateFolder.ps1"
Image="NewStandardFolder.ico" ToolbarPaintStyle="TextAndGlyph" NavigationTypes="Folder"
MultiSelectEnabled="False" />
<EditFolder Label="$UIString[MNU4]" Description="$UIString[MNU14]" Hint="$UIString[MNU10]" PSFile="EditFolder.ps1"
Image="EditFolderDatasheet.ico" ToolbarPaintStyle="TextAndGlyph" NavigationTypes="Folder"
MultiSelectEnabled="False" />
<ShowLog Label="$UIString[MNU5]" Description="$UIString[MNU15]" Hint="$UIString[MNU5]" PSFile="ShowLog.ps1"
Image="Log.ico" ToolbarPaintStyle="TextAndGlyph" MultiSelectEnabled="False" />
<AboutDialog Label="$UIString[MNU6]" Description="$UIString[MNU16]" Hint="$UIString[MNU6]"
PSFile="ShowAboutDialog.ps1" Image="About.ico" ToolbarPaintStyle="TextAndGlyph"
MultiSelectEnabled="False" />
<openURL Label="$UIString[CDN1]" Description="$UIString[CDN1]" Hint="$UIString[CDN1]"
PSFile="openURL.ps1" Image="openURL.ico" ToolbarPaintStyle="TextAndGlyph"
NavigationTypes="File,Item" MultiSelectEnabled="False" />
<exportFile Label="$UIString[CDN2]" Description="$UIString[CDN2]" Hint="$UIString[CDN2]"
PSFile="exportFile.ps1" Image="pdf.ico" ToolbarPaintStyle="TextAndGlyph"
NavigationTypes="File" MultiSelectEnabled="True" />
</MenuItem>
<!--
Label: String displayed as the label, e.g. for submenus, quoted
DeployAsPulldown: If true, used as submenu, values are true or false
Location: Specifies the location of the command site within the Vault CLient UI, values are
StandardToolbar, AdvancedToolbar, BehaviorsToolbar, ItemBomToolbar,
FileMenu, EditMenu, ActionsMenu, ToolsMenu, HelpMenu, FileContextMenu, FolderContextMenu, ChangeOrderContextMenu, ItemContextMenu
Items: list with MenuItems. Name should be same as the element name defined in the MenuItem.
-->
<CommandSite>
<FileContext Label="myMenu" DeployAsPullDown="False" Location="FileContextMenu">
<Item Name="NewFile"></Item>
<Item Name="EditFile"></Item>
<Item Name="openURL"></Item>
<Item Name="exportFile"></Item>
</FileContext>
<FolderContex Label="myMenu" DeployAsPullDown="False" Location="FolderContextMenu">
<Item Name="NewFile"></Item>
<Item Name="NewFolder"></Item>
<Item Name="EditFolder"></Item>
</FolderContex>
<StandardToolbar Label="myMenu" DeployAsPullDown="False" Location="StandardToolbar">
<Item Name="NewFile"></Item>
<Item Name="EditFile"></Item>
</StandardToolbar>
<ToolsMenu Label="myMenu" DeployAsPullDown="False" Location="ToolsMenu">
<Item Name="ShowLog"></Item>
</ToolsMenu>
<HelpMenu Label="myMenu" DeployAsPullDown="False" Location="HelpMenu">
<Item Name="AboutDialog"></Item>
</HelpMenu>
<CustomObject Label="Task" DeployAsPullDown="False" Location="Task">
<Item Name="NewTask"></Item>
<Item Name="EditTask"></Item>
</CustomObject>
<FileContext Label="myMenu" DeployAsPullDown="False" Location="ItemContextMenu">
<Item Name="openURL"></Item>
</FileContext>
</CommandSite>
<!--
Comma separated list
To suppress the command "New Library Folder" add the following two commands to the list below:
NewLibraryFolder,NewLibraryFolderForContextMenus
To suppress "Rename" for folder add this line:
Folder.Rename
-->
<SuppressMenuItems>
NewFolder,NewFolderGroupMenu,NewFolderGroupButton,NewFolderForContextMenus
</SuppressMenuItems>
</mymenu>
function Get-PropertyValueByItemNumber($number, $propertyName) {
#get item
$item = $vault.ItemService.GetLatestItemByItemNumber($number)
$itemRevision = New-Object Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.ItemRevision($vaultConnection, $item)
#get all props
$props = $vaultConnection.PropertyManager.GetPropertyDefinitions("ITEM", $null, [Autodesk.DataManagement.Client.Framework.Vault.Currency.Properties.PropertyDefinitionFilter]::IncludeAll)
#propdef of propertyname
$propertyDefinition = $props | Where-Object{$_.Value.DisplayName -eq $propertyName}
#get value
$propertyValue = $vaultConnection.PropertyManager.GetPropertyValue($itemRevision, $propertyDefinition.Value, $null)
return $propertyValue
}
#get item of context
$selectedItem = $vaultContext.CurrentSelectionSet[0]
$itemId = $selectedItem.Id
if ($selectedItem.TypeId.EntityClassId -eq "FILE") {
$file = ($vault.DocumentService.FindLatestFilesByMasterIds(@($itemId)))[0]
$item = $vaultConnection.WebServiceManager.ItemService.GetItemsByFileId($file.Id)
#$dsDiag.inspect('$item.TypeId.EntityClassId')
}
elseif ($selectedItem.TypeId.EntityClassId -eq "ITEM") {
$item = $vaultConnection.WebServiceManager.ItemService.GetItemsByIds($itemId)
}
#get property value of URL
$dsParam= Get-PropertyValueByItemNumber $item.ItemNum "URL-Link"
#start function
openURL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment