Today I had the problem to read the property mapping direction for different Vault properties from the Vault configuration. At least it was not easy to get the right result through the Vault API. But I’m not giving up so fast!
Here is the PowerShell code snipped that helps you to get the result from each property you want. I guess you have (or will have) soon the same problem and this script might help you.
[System.reflection.Assembly]::LoadFrom("C:\Program Files (x86)\Autodesk\Autodesk Vault 2013 SDK\bin\Autodesk.Connectivity.WebServices.dll") # you can pass the EntityClass, the Property Name and the name of your Provider (Inventor, AutoCAD, Inventor DWG,...) as strings # the function returns the mapping direction as MappingDirection object function GetPropertyMappingDirectionByName($entityClassId,[string] $propName,$providerName) { $propDefs = $vault.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE") $prop = $propDefs | Where-Object{$_.DispName -eq $propName} return GetPropertyMappingDirection $entityClassId $prop $providerName } #similar as GetPropertyMappingDirectionByName. But this function takes the PropDef object instead of the property name function GetPropertyMappingDirection($entityClassId,[Autodesk.Connectivity.WebServices.PropDef] $prop,$providerName) { $ret = [Autodesk.Connectivity.WebServices.AllowedMappingDirection]::None $provider = GetProviderByName $providerName $result=$vault.PropertyService.GetPropertyDefinitionInfosByEntityClassId($entityClassId, @($prop.Id))[0]; if ($result.EntClassCtntSrcPropCfgArray -ne $null) { foreach ($contentSource in $result.EntClassCtntSrcPropCfgArray) { if ($contentSource.EntClassId -ne $entityClassId -or $contentSource.CtntSrcPropDefArray -eq $null){ continue; } $CtntSrcPropDefs = @($contentSource.CtntSrcPropDefArray | Where-Object{$_.CtntSrcId -eq $provider.Id}) if($CtntSrcPropDefs -ne $null -and $CtntSrcPropDefs.Length -gt 0) { foreach ($CtntSrcPropDef in $CtntSrcPropDefs) { $i=[array]::IndexOf($contentSource.CtntSrcPropDefArray,$CtntSrcPropDef) if ($contentSource.MapDirectionArray[$i] -eq [Autodesk.Connectivity.WebServices.MappingDirection]::Read) { if($CtntSrcPropDefs.Length -eq 1){return [Autodesk.Connectivity.WebServices.AllowedMappingDirection]::Read} else {return [Autodesk.Connectivity.WebServices.AllowedMappingDirection]::ReadAndWrite } }else{ if($CtntSrcPropDefs.Length -eq 1){return [Autodesk.Connectivity.WebServices.AllowedMappingDirection]::Write} else {return [Autodesk.Connectivity.WebServices.AllowedMappingDirection]::ReadAndWrite } } } } } } return $ret } #this function returns the corresponding CtntSrc object (= Provider) for the passed in provider name #if the provider name was not found, the default provider (= Other Files) will be returned function GetProviderByName($providerName) { $config = $vault.AdminService.GetServerConfiguration(); $provider = $config.CtntSrcArray | Where-Object{$_.DispName -eq $providerName}; if ($provider -eq $null) { $provider = $config.CtntSrcArray| Where-Object{$_.SysName -eq "IFilter"}; } return $provider } #login to Vault and call the function $login = New-Object -type Autodesk.Connectivity.WebservicesTools.UserPasswordCredentials "localhost","Vault","Administrator","",$true $webSvc = New-Object -type Autodesk.Connectivity.WebServicesTools.WebServiceManager $login GetPropertyMappingDirectionByName "FILE" "Author" "AutoCAD"
The function returns the AllowedMappingDirection enum with this return values:
- Vault -> File = Write
- Vault <- File = Read
- Vault <>File = ReadAndWrite
- No mapping = None
If you want to test it you can copy/paste the code in you PowerGui and run it.