0% found this document useful (0 votes)
3 views13 pages

Filtering Numbering Schemes in VDS

VDS Tutorial - Chapter 11VDS Tutorial - Chapter 11VDS Tutorial - Chapter 11VDS Tutorial - Chapter 11
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views13 pages

Filtering Numbering Schemes in VDS

VDS Tutorial - Chapter 11VDS Tutorial - Chapter 11VDS Tutorial - Chapter 11VDS Tutorial - Chapter 11
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Vault Data Standard – Tutorial

Chapter 11 – Filter Numbering Schemes


Introduction
Data Standard allows numbering for any Vault object type. In Chapter 03, we introduced a numbering scheme for
projects that should be consumed by this category only. The same is for the custom object of type Task
introduced in Chapter 06.
If numbering schemes are directly bound to a category, the user might be clear in selecting the appropriate
scheme. In Chapter 10, we eventually broke the principle “numbering scheme name = category” because we
introduced various categories for Engineering files. This chapter talks you through the required scripting skills to
limit the selection according to any context.

Learning Objectives

- Understand how VDS handles numbering schemes


- Learn how to allow users to enable or disable Vault numbering flexibly
- Learn how to filter numbering schemes for CAD applications and Vault Explorer
- Learn how to pre-select a numbering scheme

Training Files

You must have installed all training files and folders following VDS Tutorial - Introduction and [Link]
instructions, and you need to have completed the Vault behavior configuration (Import) applied during Chapter
10. VDS configuration files of all completed exercises before this chapter can be found in the archive: .\Training
Files\VDS Configuration Files\Chapter 11\Chapter 11 – [Link].
VDS configuration files added or changed in this chapter’s exercises can be found in .\Training Files\VDS
Configuration Files\Chapter 11 – finished\.

1
Workflow

After completing all exercises, the numbering of new files, new projects or tasks follows the rules filtering
numbering schemes to the required context as shown in the images for Projects, Tasks, and Files in Vault
Explorer:

For CAD applications, all files independently of the category selection filter to the numbering scheme

“Engineering”:

Exercise 1 – Investigate Data Standard Numbering for Vault Explorer


Before we start writing new business logic to filter numbering schemes, we should get an insight: How does the
sequence of initialization, dialog loading, and code behind the dialog look like?

2
To investigate you can apply the steps learned for investigations in Chapter 10.

Step 1 – Activate a log window and trace the flow

Open the file .\[Link]\addinVault\Default.ps1. Add the calls shown below to the beginning and end of the
function InitializeWindow:

Step 2 – Review the function InitializeNumSchm

The second rule applying to all window types, InitializeNumSchm, loads available schemes and writes a default
value to the VDS system property _NumSchm.

3
Note – Using Visual Studio Code, you can easily navigate to the function's definition by positioning the cursor on
the line (e.g., InitializeNumSchm as shown above), and by hitting the F12 key.
The function contains two significant steps:
(1) Read available numbering schemes from Vault behavior configuration (Vault server). VDS applies an API call to
retrieve all active schemes for File objects.
(2) Activate the numbering scheme, if the current category selection has a corresponding name in the list of
available schemes

Step 3 – Add Trace Points to InitializeNumSchm

Add two more trace calls.

4
Step 4 – Find the Rule Filling the Pull Down List

There is no logic in the script, which pushes the list of schemes to the dialog control. Like we saw in Chapter 10
for the category pulldown list, the combo box object for numbering schemes pulls the list by a function call from
the dialog definition file [Link].

Open .\[Link]\Configuration\[Link] and search for the object name NumSchms: we can see that the
ItemsSource property binds to a PowerShell command GetNumSchms:

Back to the Default.ps1 script we search and review this function:

5
Step 5 – Add Trace Points to GetNumSchms

Add two more trace calls. (not relevant data are collapsed in following picture).

6
Step 6 – Create a new file

While creating a new file, the log window should list all tracepoints like this (no need to practice this now):

Step 7 – Identify the starting point to filter numbering schemes

The default logic in the function GetNumSchms is sorting only. The condition to initialize a sort order perfectly
matches our intent of filtering; we want to apply filtering in the same situation of having more than one scheme

available.

7
Exercise 2 – Filter Numbering Schemes for Vault Explorer

Step 1 – Define new variable $mFilteredNumSchems

Start editing the inner loop that we identified in Exercise 1 as the place to apply the filtering. Introduce a new,
empty list-variable keeping filtered numbering schemes and return this instead of the sort-ordered global list:
Add/Change

To

Step 2 – Differentiate New File, New Folder and New Custom Object Windows

As stated in the introduction, we need to apply multiple filters according to the new objects created and its
dialogs. We can achieve this by adding a switch statement as the InitializeWindow function does as a default:

8
Step 3 – Keep the Existing Logic for any other Window Type

The previous rule of sort-ordering may apply to other window names, that we do not know yet. It is a good
practice to use the Switch – Default condition for such “unforeseen” events. But be cautious – the list to return is
no longer the global variable $numSchems but our new one $mFilteredNumSchems; move the existing line and
update the variable as highlighted in the image:

Do not forget to add the sorted list instead of assigning it: “+=” instead of “=”.

Step 4 – Complete the Filter for each Window Type

Each Window type uses different filter criteria, but all follow a universal principle of filtering the global list of all
available numbering schemes to the category name and adding (“+=”) it to the empty list of filtered schemes:

Note – The list of global numbering schemes contains Vault objects of type Numbering Scheme, not only the
names. For this reason, we need to look-up the object’s name: $_.Name.

Step 5 – Allow a “None” Scheme Selection

Save Default.ps1
If you run the code as-is, you will recognize that for new folders, users can turn on the numbering, but there is no
way to return to a manual folder name:

9
.
To solve this limitation and to add more flexibility in general, we add an option to unselect any numbering by
adding a “None” scheme. From a script logic perspective, we add (2) a new empty numbering scheme object of
the name “None” (1) to our filtered list (2):

Save Default.ps1
We did this before the filtered list returns to the dialog; if you liked to limit the “None” selection to folders only,
you would move the scripted action within the switch “Folder” condition.

10
As the last step, you might turn off (comment) the log window display; the finalized script in the training files did
this accordingly.

Exercise 3 – Filter Numbering Schemes for CAD


The principle of initializing all numbering schemes and loading these to the combo box of the dialog that we
discovered in Exercise 1 for Vault Explorer applies to CAD also. The tracepoints added to the same functions
InitializeWindow, InitializeNumSchms, and GetNumSchms (in .\[Link]\addins\Default.ps1) report the same
order of the tracing points to the log as we saw in Exercise 1 for Vault Explorer:

11
Step 1 – Define new variable $mFilteredNumSchems

Start by reviewing the inner loop of the function GetNumSchms for CAD: as we identified in Exercise 1, there is an
inner condition ($[Link] -gt 1) that applies the filtering. We keep the condition and change the sort-
order action to a filter action. Introduce a new, empty list-variable keeping filtered numbering schemes and
return this instead of the sort-ordered global list:

Step 2 – Add the Engineering Scheme to the List

Filter the global list of available numbering schemes to the “Engineering” named one:

Step 3 – Pre-Select Scheme in the Pull-Down-List

As we filtered to a single scheme the pull-down-list should select this value automatically; look-up the name of
the control in the [Link] or [Link] file and set
the property SelectedValue:

[Step 4 Optional] – Allow a None Scheme Selection

In case you want to allow a “None” scheme in general and not only for the export file context, remove the
condition and add the none scheme to the array of filtered before it returns:

12
As a result, a save new file event in Inventor (and AutoCAD as well) activates the scheme “Engineering” in the
dialog and allows the switch to the “None” scheme:

Take Away
Again, this chapter might challenge students who are not familiar with PowerShell scripting yet. If you belong to
this group, keep your motivation reading as much sample scripts as possible. We solved all tasks by following
three frequently used concepts and best practices:

1) Use Switch statements and conditions instead of multiple If conditions; it allows to cover a condition that
you did not think of while implementing
2) Use the pipeline (“pipe” character “|”) concept like a For...Next loop in other script languages. The
Where-Object querying each element $_ reflects the if condition within a For...Next loop. Admitted – a
For..Next or For..Each..In loops might look more self-explaining; but, PowerShell script authors love
piping. You will find it nearly everywhere, as it allows iterating through a list or collection while querying
specific data and implementing a single line of code.
3) Working with arrays. As a best practice, always declare an empty array ( = @() ) and add members to it,
even it is a single member only ( += ).

Suppose you are eager to use Data Standard to build complex rules and business logic. In that case, I recommend
signing up for a PowerShell Tutorial on the web beside this Data Standard Tutorial.

13

You might also like