A XAML control called DSNumSchemeCtrl is used to support numbering schemes in the Data Standard dialogs for the Vault Client, Inventor Vault Add-in, and AutoCAD Vault add-in.
Numbering Scheme UI
The following lines are required in the XAML file to show the UI controls displayed in the preceding image.
... <Label Content="{Binding UIString[LBL10]}" Grid.Column="0" Grid.Row="6" /> <ComboBox Grid.Column="1" Grid.Row="6" Name="NumSchms" SelectedIndex="0" Style="{StaticResource NumSchmStyle}"></ComboBox> <Label Content="{Binding UIString[LBL31]}" Grid.Column="0" Grid.Row="8"></Label> <WPF:DSNumSchemeCtrl Grid.Column="1" Grid.Row="8" Name="NUMSCHEME" IsEnabled="{Binding ElementName=NumSchms, Path=IsEnabled}" Scheme="{Binding ElementName=NumSchms, Path=SelectedItem}" GeneratedNumberProperty="_GeneratedNumber" /> ...
Use this attribute to specify the name of the numbering scheme that should be displayed in the control. In the sample, this value is bound to the selected entry in the combo box above the control. By default, the combo box contains all activated file numbering schemes. Refer to Filtering Numbering Schemes section in this topic to see how you can filter the numbering schemes.
Use this attribute to define which property holds the generated number. When clicking the OK button, the number for each DSNumSchemeCtrl is generated and assigned to the specified property.
In the default sample, the value in the property _GeneratedNumber plus the file extension determines the filename that is used to create the new file. In the next section are samples for Vault Explorer and CAD that use the generated number as well as some other property values to build the filename for the new file ("Customize the Filename"). Currently one DSNumSchemeCtrl per dialog is supported.
For Inventor and AutoCAD, a PowerShell function named OnPostCloseDialog is called when closing the Data Standard dialog.
The function gets called before the file name is set and before updating the iProperties. This timing allows the code to still modify properties before the file is saved. This could be useful when users are not required to select a numbering schemes (see sample "Use Vault Numbering without showing the Number Scheme Control in the Dialog" for CAD in the next section).
By default the function OnPostCloseDialog in the CAD Default.ps1 doesn't do anything.
Parameters
When the OnPostCloseDialog function is called, the PowerShell variable $DSParam is set to the following possible values:
Vault Data Standard dialog in "CreateMode" for a single file.
Vault Data Standard dialog in "EditMode" for a single file.
Additionally the variable $dsWindow.Name contains the dialog name. By default that is either InventorWindow or AutoCADWindow.
These variables can be used to provide different implementations for different scenarios.
In the installed sample, the Number Scheme combo box shows all activated numbering schemes. In the XAML file, the combo box is bound to a PowerShell function called GetNumSchms.
The GetNumSchms function makes it easy to control which schemes should be shown to the user.
Filtering Numbering Schemes in Inventor Based on File Type
Without Data Standard, the user can always select between all activated Vault numbering schemes. With the following implementation of GetNumSchms, different schemes will be available for components (IPT, IAM) and drawings (IDW, IPN and DWG). To make the sample work, numbering schemes that start with "COMP" or "DRAWING" need to be defined in Vault:
C:\ProgramData\Autodesk\Vault 2015 R2\Extensions\DataStandard\CAD\addinVault\Default.ps1
... function GetNumSchms { try { $numSchems = $vault.DocumentService.GetNumberingSchemesByType('Activated') } catch [System.Exception] { #[System.Windows.MessageBox]::Show($error) } $fileName = $Prop["DocNumber"].Value $fileExt = [System.IO.Path]::GetExtension($fileName) $ret = @() foreach ($item in $numSchems) { if (($fileExt -eq ".iam" -or $fileExt -eq ".ipt") -and $item.Name.StartsWith("COMP")) { $ret += $item.Name } elseif (($fileExt -eq ".idw" -or $fileExt -eq ".ipn" -or $fileExt -eq ".dwg") -and $item.Name.StartsWith("DRAWING")) { $ret += $item.Name } } return $ret } ...
Consider that you have the following numbering scheme called TestScheme.
Now you want to pre-pend the filename with a fixed text based on the selected document type:
When clicking OK in the CreateFileDialog ("New Standard File ..."), the PowerShell function GetNewFileName is called before adding the file to Vault. Here you have the chance to modify the filename and include information from other properties.
C:\ProgramData\Autodesk\Vault 2015 R2\Extensions\DataStandard\Vault\addinVault\Default.ps1
... function GetNewFileName { $prefix = "" if($dsWindow.FindName("NUMSCHEME").IsEnabled -eq $false) { $fileName = $dsWindow.FindName("FILENAME").Text } else{ $fileName = $Prop["_GeneratedNumber"].Value if (($Prop["_FileExt"].Value -eq ".ipt") -or ($Prop["_FileExt"].Value -eq ".iam")) { $prefix = "ENG-" } elseif (($Prop["_FileExt"].Value -eq ".dwg") -or ($Prop["_FileExt"].Value -eq ".idw") -or ($Prop["_FileExt"].Value -eq ".ipn")) { $prefix = "ENGDOC-" } else { $prefix = "OFF-" } } $newfileName = $prefix + $fileName + $Prop["_FileExt"].Value return $newfileName }
With Data Standard for Inventor and AutoCAD, you can configure a combination of property values and a generated number for the filename.
For example, let's say that you want to automatically create unique file names in the format of: "N-<Title>-####.ipt where N- is always applied, <Title> is the user-entered Title property, #### is a number automatically generated, and .ipt is the file extension.
This can be done by modifying the element <FileNameDefinition> in Inventor.cfg or the AutoCAD.cfg files.
C:\ProgramData\Autodesk\Vault 2015 R2\Extensions\DataStandard\CAD
<?xml version="1.0" encoding="utf-8"?> <Configuration> <PathDefinition>{Workspace}\{Prop[Folder].Value}</PathDefinition> <FileNameDefinition>N-{Prop[Title].Value}-{Prop[DocNumber].Value}</FileNameDefinition> <PropertyDefinitions> <PropertyDefinition PropertyName="DocNumber" DataType="Text" InitialValue="{PathAndFileNameHandler.FileName}" /> ...
The property DocNumber contains the generated number, because it is defined in attribute GeneratedNumberProperty="DocNumber" in the DSNumSchemeCtrl control of the Inventor.xaml file.
By removing the DSNumSchemeCtrl and the NumSchms combo box from the default File.xaml file, the user cannot select a numbering scheme anymore.
Data Standard for Vault
The following sample implementation of GetNewFileName uses the numbering scheme "TestScheme" from above and the value entered in "Title" as a parameter for the numbering scheme.
C:\ProgramData\Autodesk\Vault 2015 R2\Extensions\DataStandard\Vault\addinVault\Default.ps1
... function GetNewFileName { $numSchemes = $vault.DocumentService.GetNumberingSchemesByType([Autodesk.Connectivity.WebServices.NumSchmType]::Activated) $testNumScheme = $numSchemes | Where-Object { $_.Name.Equals("TestScheme") } $NumGenArgs = @() $NumGenArgs += $Prop["Title"].Value $genNum = $vault.DocumentService.GenerateFileNumber($testNumScheme.SchmID, $NumGenArgs) return $genNum + $Prop["_FileExt"].Value } ...
Data Standard for CAD
For Inventor and AutoCAD, the implementation is similar to the sample above. But instead of returning a filename, the property "DocNumber" has to be filled with a generated number. This property is then used to set the name for the current file:
C:\ProgramData\Autodesk\Vault 2015 R2\Extensions\DataStandard\CAD\addinVault\Default.ps1
... function OnPostCloseDialog { if ($DSParam -eq "Create") { $numSchemes = $vault.DocumentService.GetNumberingSchemesByType([Autodesk.Connectivity.WebServices.NumSchmType]::Activated) $testNumScheme = $numSchemes | Where-Object { $_.Name.Equals("TestScheme") } $NumGenArgs = @() $NumGenArgs += $Prop["Title"].Value $genNum = $vault.DocumentService.GenerateFileNumber($testNumScheme.SchmID, $NumGenArgs) $Prop["DocNumber"].Value = $genNum } } ...