Share
 
 

PowerShell Functions for Data Standard

PowerShell functions are used to programmatically customize business logic, behavior, default values, and the user interface.

Data Standard comes with several functions that are required to work with the standard dialogs and tabs. Some functions are called from inside the Data Standard Add-Ins.

These functions are mandatory and should not be removed.

The functions can be regarded as event driven functions and can be modified to change the behavior. Other functions are called directly from the XAML file. For example, to retrieve information from the Vault database (e.g., available numbering schemes, categories).

All *.ps1 and *.psm1(PowerShell module) files that are located in the "addinVault" (Vault) or "addins" (CAD) folders are automatically imported and used.

Note: Autodesk recommends using a separate .ps1 file for your own functions.

The following chart contains a list of the functions that are directly called either from an Add-In or from a XAML file. For better readability of the code, these functions may call other functions. These other functions, are not explicitly listed.

Function

File

Usage Add-in

Usage XAML

Description

ActivateOKButton

Vault: Default.ps1

Vault

Used for validation and enabling the OK button in edit and create dialogs. By default it calls the function Validate() which then, based on the window type, calls further validation functions.

Because ActivateOkButton is called every time data is changed on the dialog, this can cause performance problems if the validation functions are too complex.

AddinLoaded

CAD: Default.ps1

CAD

Called when the VDS Inventor- or AutoCAD-Addin is loaded.

Addinunloaded

CAD: Default.ps1

CAD

Called when the VDS Inventor- or AutoCAD-Addin is unloaded.

GetCategories

Vault,

CAD: Default.ps1

Vault, CAD

This function is used in the create dialogs for Vault and CAD to show categories in a combo box.

The default implementation returns a list of all file, folder, or custom entity categories based on the window name. Used for Dynamic Properties. For CAD edit dialogs, the assigned category is returned.

GetNewCustomObjectName

Vault: Default.ps1

Vault

Called when clicking the OK button in a create custom object dialog. This function returns the name of the new custom object. The default implementation either gets the value from a create dialog control with the name CUSTOMOBJECTNAME or from a special property _GeneratedNumber if Vault numbering schemes are defined. See Data Standard and Numbering Schemes for more information.

GetNewFileName

Vault: Default.ps1

Vault

Called when clicking the OK button in a create file dialog. This function returns the filename of the new file. The default implementation either gets the value from a create dialog control with the name FILENAME or from a special property _GeneratedNumber if Vault numbering schemes are defined. See Data Standard and Numbering Schemes for more information.

GetNewFolderName

Vault: Default.ps1

Vault

Called when clicking the OK button in a create folder dialog. This function returns the name of the new folder. The default implementation either gets the value from a create dialog control with the name FOLDERNAME or from a special property _GeneratedNumber if Vault numbering schemes are defined. See Data Standard and Numbering Schemes for more information.

GetNumSchms

Vault,

CAD: Default.ps1

Vault, CAD

This function is used in file create dialogs for Vault and CAD to show numbering schemes in a combo box. The default implementation returns all activated Vault file numbering schemes. The default numbering scheme is a scheme with the same name as the selected category. If a scheme does not exist with the same name as the selected category, the scheme is the default scheme set in the Vault settings.

GetParentFolderName

Vault: Default.ps1

Vault

Called when clicking the OK button in a create folder dialog. This function can be used to force a specific folder name when using New Standard File or New Standard Folder functions. If an empty string is returned the selected folder is used.

InitializeTabWindow

Vault: Default.ps1

Vault

Called when initializing Data Standard tabs in Vault.

InitializeWindow

Vault: Default.ps1

Vault

Called when initializing Data Standard dialogs.

ItemTitle

Vault: Default.ps1

Vault

Used in tabs for Item and ECO objects. The default implementation returns the value of the item or ECO "Title (item,CO)" property.

Note: {Binding Prop[_XLTN_TITLE_ITEM_CO]} cannot be used directly in the XAML because of the property name.

ItemDescription

Vault: Default.ps1

Vault

Used in tabs for Item and ECO objects. The default implementation returns the value of the item or ECO "Description (item,CO)" property.

Note: {Binding Prop[_XLTN_DESCRIPTION_ITEM_CO]} cannot be used directly in the XAML because of the property name.

OnLogOn

Vault: Default.ps1

Vault

Called when a user logs into a vault.

OnLogOff

Vault: Default.ps1

Vault

Called when the user logs off.

OnPostCloseDialog

CAD: Default.ps1

CAD

Called when the Data Standard dialogs is closed by clicking the OK button, and before the filename is set the properties are updated.

OnTabContextChanged

Vault: Default.ps1

Vault

Called when the context of a custom tab in Vault changes. Is used to update the data that is shown in the tab.

SetWindowTitle($newFile, $editFile, $name)

Vault, CAD: Default.ps1

Vault, CAD

Called from InitializeWindow function. This function is fed with inputs depending on CreateMode or EditMode as well as whether it is for File, Folder or CustomObject. The output that is returned is set as the title of the Dialog.

Note: The ps1-files for the menu items, located in C:\ProgramData\Autodesk\<Vault version>\Extensions\DataStandard\Vault\addinVault\Menus, contain code which is not in the scope of a PowerShell function. This code is executed directly when the menu item is clicked.

Was this information helpful?