Numbering with Data Standard

numbering

When using Vault Numbering Schemes without Data Standard you will notice some shortcomings. Just to name some examples: The user always sees all active numbering schemes when creating new file in Inventor or AutoCAD. It cannot be enforced that a numbering scheme is used when creating new files (the user can skip the dialog). Numbering schemes don’t have fields that can be controlled by properties.

With Data Standard 2015 R2 support for Vault Numbering Schemes has been introduced. Together with the adaptability of Data Standard this can be used to solve the challenges mentioned above.

A numbering scheme requires actually a dynamic number of different controls such as labels, text- and combo boxes depending on the definition. The good news is that you don’t have to define each of these controls in your XAML file. Instead you just need to add one line to get a numbering scheme control:

...
<WPF:DSNumSchemeCtrl Grid.Column="1" Grid.Row="8" Scheme="{Binding ElementName=NumSchms, Path=SelectedItem}" GeneratedNumberProperty="_GeneratedNumber"/>
...

The control has built-in validation. For example when you’ve defined a free text field in your numbering scheme that requires exactly three characters, it would look like this:

NumberingValidation

Please note that for Inventor and AutoCAD the native Vault numbering scheme dialog doesn’t come up anymore as long as Data Standard is enabled.

Let’s do some modifications to the standard behavior!
The control has two mandatory attributes, so called dependency properties. It’s basically an input and an output “parameter” for the control.

“Scheme” (input)
Here the name of the numbering scheme definition has to be specified.
In the sample delivered with Data Standard this is bound to the selected element of a combo box, which gets its values from the PowerShell function “GetNumSchms”. With this the list of numbering schemes can be easily filtered by modifying the “GetNumSchms” function.

The following sample shows different numbering schemes based on the selected category when using the function “New Standard File …” in Vault.

NumberingFilter
First of all we need to change the function “GetNumSchms”:

function GetNumSchms
{
    $ret = @()
    $global:numSchems = $vault.DocumentService.GetNumberingSchemesByType([Autodesk.Connectivity.WebServices.NumSchmType]::Activated)
    foreach ($item in $numSchems)
    {
        switch ($Prop["_Category"].Value)
        {
            "Engineering"
            {
                if ($item.Name.StartsWith("ENG")) {$ret += $item.Name}
                break
            }
            "Office"
            {
                if ($item.Name.StartsWith("OFF")) {$ret += $item.Name}
                break
            }
            "Standard"
            {
                if ($item.Name.StartsWith("STD")) {$ret += $item.Name}
                break
            }
            default {$ret += $item.Name}
        }
    }
    return $ret
}

To run the sample you need to define numbering schemes starting with “ENG”, “OFF” and “STD”. When the dialog is shown the function “GetNumSchms” gets called. Based on the selected category (bound to property “_Category”) it adds only specific numbering schemes to the list that gets returned by this function.

The sample is not quite working yet. The combo box that shows the available numbering schemes has to be updated when another category is selected. To do this we need an event handler that gets called when the property “_Category” changes.

...
function InitializeWindow
{
    ...
    $Prop["_Category"].add_PropertyChanged({
                    param($object, $arg)
                    Category_OnPropertyChanged $arg
    })
}
...

function Category_OnPropertyChanged
{
    param($arg)
    $argname = $arg.PropertyName
    if($arg.PropertyName -eq "Value")
    {
        $numSchmCtrl = $dsWindow.FindName("NumSchms")
        $numSchmCtrl.GetBindingExpression([System.Windows.Controls.ComboBox]::ItemsSourceProperty).UpdateTarget()
        $numSchmCtrl.SelectedIndex = 0
    }
}

“GeneratedNumberProperty” (output)
Here you have to tell the control to which property the generated number has to be saved, once the user clicks the OK button.
You still have the chance to modify the generated number before the file gets created.

For Inventor or AutoCAD the “GeneratedNumberProperty” is set to “DocNumber”. The following sample Inventor.cfg shows how to add the value of the title property to the generated number (don’t know if that makes sense but you get the point):

<?xml version="1.0" encoding="utf-8"?>
<Configuration>
    <PathDefinition>{Workspace}\{Prop[Folder].Value}</PathDefinition>
    <FileNameDefinition>{Prop[DocNumber].Value}-{Prop[Title].Value}</FileNameDefinition>
    <PropertyDefinitions>
        <PropertyDefinition PropertyName="DocNumber" DataType="Text" InitialValue="{PathAndFileNameHandler.FileName}" />
...

To do more sophisticated things you can override the PowerShell function “OnPostCloseDialog” for Inventor and AutoCAD or the “GetNewFileName” function for Vault. These functions can be found in the “default.ps1” file.

I hope this information was helpful to get started with numbering schemes in Data Standard.

 

 

This entry was posted in Data Standard. Bookmark the permalink.

One Response to Numbering with Data Standard

  1. DS2016:
    $ret = New-Object ‘System.Collections.Generic.List[System.Object]’
    instead of $ret = @()
    $ret.Add($item)
    instead of $ret += $item.Name

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s