Leverage Vault numbering schemes to enforce file names when a user creates a new Data Standard file.
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 Version>\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 } ...
Data Standard for Vault
Consider 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 Create File Dialog (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 Version>\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 }
Data Standard for CAD
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 Version>\Extensions\DataStandard\CAD\Inventor.cfg
<?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}" /> ...
Data Standard for Vault
The following sample implementation of GetNewFileName uses the numbering scheme TestScheme from above and the value entered in the Title as a parameter for the numbering scheme.
C:\ProgramData\Autodesk\<Vault Version>\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 Version>\Extensions\DataStandard\CAD\addinVault\Default.ps1
... function OnPostCloseDialog { if ($Prop["_CreateMode"].Value) { $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 } } ...