Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Required Text Box

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
DesignEng
521 Views, 2 Replies

Required Text Box

We installed Autodesk data Standard to our Vault. I am trying to make a text box in the "New File" dialog window a required entry (mandatory entry). This is the dialog that appears when adding a "New Standard File..." (when you right click in the Navigation Pane).

 

Any help would be greatly appreciated!

 

2 REPLIES 2
Message 2 of 3
marco.mirandola
in reply to: DesignEng

in Data Standard, you have to distinguish between Data Standard for CAD or for Vault. The difference is that in DS for CAD, you have to configure which fields you like to use in the dialog via the according cfg file (Inventor.cfg or AutoCAD.cfg). In such cfg file, you can also define whether a field is obligatory or not. The cfg file is needed, as the iProperties used in CAD are different from the properties in Vault.

 

In Data Standard for Vault, which is the case you describe, there is no need for a CFG file, as the properties used in the dialog, are the one defined in Vault. Therefore, in order to set a property obligatory, you have to write few lines of code in a PS1 file. Now, if you have a look into the default.ps1, you will find a function called ActivateOkButton. This is how this function looks like:

function ActivateOkButton
{
	return Validate;
}

 this function calls the Validate function, which looks like this:

function Validate
{
	$mWindowName = $dsWindow.Name
	switch($mWindowName)
	{
		"FileWindow"
		{
			foreach ($func in dir function:ValidateFile*) { if(!(&$func)) { return $false } }
			return $true
		}
.....
... }

 You will notice that this function, for the case of a FileWindow, goes through all the functions that are called VaildateFile (see $func in dir function:ValidateFile*). This means that there will be some functions all called ValidateFile..... On of such function, for instance, is the ValidateFileTitle:

function ValidateFileTitle
{
	if($Prop["_XLTN_TITLE"].Value) { return $true}
	return $false;
}

 As you can see, this function does nothing but checking if the property Title. The _XLTN_ prefix is for localization purpose, so you can ignore it. If the property contains a value, then the function returns true, otherwise it returns false.

 

bottom line is, in order to have a check on your property, just create a simple function like this:

function ValidateFileMyProperty
{
	if($Prop["MyPropertiy"].Value) { return $true}
	return $false;
}

 Where MyProperty is of course the name of your property. You can save this function in a custom ps1. So, just create a PS1 file nearby the default.ps1 and insert the function above. replace the MyProperty with the name of your property, and you are set.

 

If you notice, in such function, you can also check more then just if it contains a value or not. you could check if the value matches some criteris, such as first letter must be upper case, or a number, or the text must contain at least 5 characters, or must end with ...., or does not contains some special characters. So, the validation can be made quite powerful. you could also make a field obligatory just in case another field is not set or set with a particular value. So, the flexibility is huge!

 

i hope this helps!

coolOrange
www.coolorange.com
Message 3 of 3
DesignEng
in reply to: marco.mirandola

Thank you for your detailed response. It works great! Thank you so much for your help with this.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report