Skip to content

Instantly share code, notes, and snippets.

@slydlake
Last active October 26, 2021 08:53
Show Gist options
  • Save slydlake/c0f7558b797be0b44a6349a4166c5cb7 to your computer and use it in GitHub Desktop.
Save slydlake/c0f7558b797be0b44a6349a4166c5cb7 to your computer and use it in GitHub Desktop.
[VDS Export Files] #VDS #powershell
Function Get-Folder($initialDirectory="")
{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")|Out-Null
$foldername = New-Object System.Windows.Forms.FolderBrowserDialog
$foldername.Description = "Ordner der Exportdateien"
$foldername.rootfolder = "Desktop"
$foldername.SelectedPath = $initialDirectory
if($foldername.ShowDialog() -eq "OK")
{
$folder += $foldername.SelectedPath
}
return $folder
}
$global:CIDEON_GENERAL_TOOLS = New-Object -TypeName CIDEON.GENERAL.TOOLS.CIDEON_GENERAL_TOOLS
$global:CIDEON_VAULT_DOCUMENT_TOOLS = New-Object -TypeName CIDEON.VAULT.DOCUMENT.TOOLS.CIDEON_VAULT_DOCUMENT_TOOLS($VaultConnection)
$selection = $vaultContext.CurrentSelectionSet
if ($selection){
$exportFolder = Get-Folder
}
#$filelist = New-Object Collections.Generic.List[Autodesk.Connectivity.WebServices.File]
foreach ($selected in $selection){
$file = $CIDEON_VAULT_DOCUMENT_TOOLS.CDN_GetLatestFileObjectByMasterFileID($selected.Id);
#$filelist.Add($file)
#Properties für das Lesen zusammenstellen
$ReadProps = New-Object 'System.Collections.Generic.List[String]'
$ReadProps.Add("Artikelnummer")
$ReadProps.Add("Titel")
$ReadProps.Add("Revision")
$ReadProps.Add("Druck")
$GetProps = $CIDEON_VAULT_DOCUMENT_TOOLS.CDN_FileGetProperties($file, $ReadProps)
#Wenn Eigenschaften vorhanden mergen
$filename = $GetProps["Artikelnummer"], $GetProps["Titel"] -join " "
#Index
$filename = $filename.Trim() + " Ind" + $GetProps["Revision"]
#wenn Druck
if ($GetProps["Druck"]){
$filename = $filename + " Druck" + $GetProps["Druck"]
}
$filename = $filename.Trim()
$DownloadPfad = $exportFolder + "\" + $filename + $CIDEON_GENERAL_TOOLS.CDN_GetExtension($file.Name)
#[System.Windows.Forms.MessageBox]::Show($DownloadPfad)
$CIDEON_VAULT_DOCUMENT_TOOLS.CDN_DownloadFileByID($file.Id,$DownloadPfad)
}
#$CIDEON_VAULT_DOCUMENT_TOOLS.CDN_DownloadFilesFromFileObjektListToExportPath($DownloadPfad, $filelist)
#$dsDiag.inspect('$filelist')
#[System.Windows.Forms.MessageBox]::Show($DownloadPfad)
#$dsDiag.inspect('$DownloadPfad')
<?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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment