Vault Data Standard to get vault folder properties

Vault Data Standard to get vault folder properties

Anonymous
Not applicable
1,908 Views
4 Replies
Message 1 of 5

Vault Data Standard to get vault folder properties

Anonymous
Not applicable

Hi Guys

 

What i would like to achieve.

 

Create a new file in vault using data standard, in the data standard dialog box i would like the properties to be populated from the vault folder properties that the file is going to be created in.

 

I have got it right to auto populate the properties i require from a ps1 file based on client name, the winner would be to achieve this by getting the properties from the folder.

 

Example

 

Folder name is E300, E300 folder Client name property is Test. When i right click on the E300 folder in vault and select new standard file the data standard dialog box must pull through the client name folder property test without having to manually type it in. 

 

Any help on this will be appreciated.

 

Thanks.

0 Likes
Accepted solutions (1)
1,909 Views
4 Replies
Replies (4)
Message 2 of 5

Markus.Koechl
Autodesk
Autodesk
Accepted solution

Find below a sample code to do this. The file might reside in a subfolder of your project: the code iterates from the file to each parent folder and stops finding the project category based one. From this the properties are retrieved.

#region derive folder props
function mDeriveProjectProperties
{
					#region InheritProjektIDtoFile
				# Retrieve Projekt ID for project type folders
				$Global:mProjectFound = $false
				$_DataContext = $dsWindow.DataContext
				$mPath = $Prop["_FilePath"].Value
				$mFld = $vault.DocumentService.GetFolderByPath($mPath)
	
				IF ($mFld.Cat.CatName -eq $UIString["CAT6"]) { $Global:mProjectFound = $true}
				Else {
					Do {
						$mParID = $mFld.ParID
						$mFld = $vault.DocumentService.GetFolderByID($mParID)
						IF ($mFld.Cat.CatName -eq $UIString["CAT6"]) { $Global:mProjectFound = $true}
					} Until (($mFld.Cat.CatName -eq $UIString["CAT6"]) -or ($mFld.FullName -eq "$"))

				}

				If ($mProjectFound -eq $true) {
					
					$Prop["Project"].Value = mGetFolderPropValue $mFld.Id "Name"
					$Prop["Description"].Value = mGetFolderPropValue $mFld.Id "Description"

				}
				# 				$dsDiag.Inspect()
				#endregion
}


function mGetFolderPropValue ([Int64] $mFldID, [STRING] $mDispName)
{
	$PropDefs = $vault.PropertyService.GetPropertyDefinitionsByEntityClassId("FLDR")
	$propDefIds = @()
	$PropDefs | ForEach-Object {
		$propDefIds += $_.Id
	} 
	$mPropDef = $propDefs | Where-Object { $_.DispName -eq $mDispName}
	$mEntIDs = @()
	$mEntIDs += $mFldID
	$mPropDefIDs = @()
	$mPropDefIDs += $mPropDef.Id
	$mProp = $vault.PropertyService.GetProperties("FLDR",$mEntIDs, $mPropDefIDs)
	$mProp | Where-Object { $mPropVal = $_.Val }
	Return $mPropVal
}

#endregion

Hope this helps!



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
Message 3 of 5

Anonymous
Not applicable

Hi Markus

 

Thank you very much for the response.

 

I have placed the code in a separate ps1 file called get folder properties. My project folder is a folder project which is "CAT6"

 

I have added this to the code for testing

 

$Prop["Project No."].Value = mGetFolderPropValue $mFld.Id "Project No."
$Prop["Description"].Value = mGetFolderPropValue $mFld.Id "Description"
$Prop["Client"].Value = mGetFolderPropValue $mFld.Id "Client"

 

The folder Project No. value is E500

The folder Description value is test

The folder Client value is adam

 

 

In vault when i right click on the folder to create a new file the above mentioned properties do not show in the data standard dialog box.

 

 

Thanks

Adam

0 Likes
Message 4 of 5

Anonymous
Not applicable

Hi Markus

 

Thank you very much.

 

All is working it would help if i would call the fuction.

 

Thanks again

 

Adam.

0 Likes
Message 5 of 5

Anonymous
Not applicable

Hi Markus

 

Sorry i know this post is solved, but i have another question.

 

Is there a way to pull the parent folder properties through to the sub-folder properties in data standard like the code you sent me below that works when i create a new file it gives me the folder properties, Now when i create a new sub-folder in a parent folder i would also like the inherit the parent folder properties.

 

Thanks

Adam.

0 Likes