How to programatically Update Properties from Vault (VaultPropertyWriteBack)

How to programatically Update Properties from Vault (VaultPropertyWriteBack)

Anonymous
Not applicable
4,883 Views
5 Replies
Message 1 of 6

How to programatically Update Properties from Vault (VaultPropertyWriteBack)

Anonymous
Not applicable

I'm using:

 

_app.CommandManager.ControlDefinitions["VaultPropertyWriteBack"].Execute(); 

 

This opens up a dialog box. I want to do the Update Properties after checking out a file without the popup. Is there a method in the SDK that duplicates this functionality?

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

Markus.Koechl
Autodesk
Autodesk
Accepted solution

You are calling a user interface command that does not have an option to suppress the dialog. However, you could enforce updating properties on check out and set the option "Yes to all" & "Never Prompt". VaultInventorOptionsUpdatePropsYesToAllNeverPrompt.png

The Vault SDK does not have a corresponding function for this specific task of the Inventor Add-In. For a full programmatically executed approach, you could re-use the existing connection of the Inventor-Vault session, query the file's property from Vault and write the values to the file that you are handling.

 



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 3 of 6

dg2405
Advocate
Advocate

Do you have a sample for updating the file properties programmatically via vault api?

I know Inventor API very good but Vault... 🤔

The only thing I've done was to get the current Revision via Ilogic from Inventor:

Dim mVltCon As VDF.Vault.Currency.Connections.Connection = VB.ConnectionManager.Instance.Connection
If mVltCon Is Nothing Then Exit Sub
Dim VaultPath As String = ThisDoc.PathAndFileName(True)
VaultPath = VaultPath.Replace("C:\Vault-Workspace\", "$/")
VaultPath = VaultPath.Replace("\", "/")
Dim VaultPaths() As String = New String() {VaultPath}
Dim wsFiels() As AWS.File = mVltCon.WebServiceManager.DocumentService.FindLatestFilesByPaths(VaultPaths)
Dim mFileIt As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(conn,wsFiels(0))
Dim lifeCycleInfo As VDF.Vault.Currency.Entities.FileLifecycleInfo = mFileIt.LifecycleInfo
Dim fileRevInfo As VDF.Vault.Currency.Entities.FileRevisionInfo = mFileIt.RevisionInfo
Dim CurrentRev As String = fileRevInfo.RevisionLabel

 

0 Likes
Message 4 of 6

Markus.Koechl
Autodesk
Autodesk

The code below updates multiple properties of a file:

//synchronize source file properties to export file properties for UDPs assigned to both
            try
            {
                mTrace.WriteLine("Job tries synchronizing export file's properties in Vault.");
                //get the design rep category's user properties
                ACET.IExplorerUtil mExplUtil = Autodesk.Connectivity.Explorer.ExtensibilityTools.ExplorerLoader.LoadExplorerUtil(
                            connection.Server, connection.Vault, connection.UserID, connection.Ticket);
                Dictionary<ACW.PropDef, object> mPropDictonary = new Dictionary<ACW.PropDef, object>();
                //get property definitions filtered to UDPs
                VDF.Vault.Currency.Properties.PropertyDefinitionDictionary mPropDefs = connection.PropertyManager.GetPropertyDefinitions(
                    VDF.Vault.Currency.Entities.EntityClassIds.Files, null, VDF.Vault.Currency.Properties.PropertyDefinitionFilter.IncludeUserDefined);

                //get property definitions assigned to Design Representation category
                ACW.CatCfg catCfg1 = mWsMgr.CategoryService.GetCategoryConfigurationById(mExpFile.Cat.CatId, new string[] { "UserDefinedProperty" });
                List<long> mFilePropDefs = new List<long>();
                foreach (ACW.Bhv bhv in catCfg1.BhvCfgArray.First().BhvArray)
                {
                    mFilePropDefs.Add(bhv.Id);
                }

                //get properties assigned to source file and add definition/value pair to dictionary
                ACW.PropInst[] mSourcePropInst = mWsMgr.PropertyService.GetProperties("FILE", new long[] { mFile.Id }, mFilePropDefs.ToArray());
                ACW.PropDef[] propDefs = connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE");
                foreach (ACW.PropInst item in mSourcePropInst)
                {
                    VDF.Vault.Currency.Properties.PropertyDefinition mPropDef = connection.PropertyManager.GetPropertyDefinitionById(item.PropDefId);
                    ACW.PropDef propDef = propDefs.SingleOrDefault(n => n.Id == item.PropDefId);
                    mPropDictonary.Add(propDef, item.Val);
                }

                //update export file using the property dictionary; note this the IExplorerUtil method bumps file iteration and requires no check out
                mExplUtil.UpdateFileProperties(mExpFile, mPropDictonary);

            }

To get the full context of all references used, you may download the full example from here: https://github.com/koechlm/Vault-Sample---STEPExportJob

 



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
Message 5 of 6

dinesh_nimbalkar
Observer
Observer

Hello Markus,

 

Could you please check github repo link? For me its not working..saying page not found.

 

Thank you.

0 Likes
Message 6 of 6

Markus.Koechl
Autodesk
Autodesk

Hi @dinesh_nimbalkar : I am sorry for the wrong link. Here is the working one: Vault-Sample---InventorExportAnySampleJob/Autodesk.VLTINVSRV.ExportSampleJob/JobExtension.cs at 2025...



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe