Hi, In order to do this, you need to use the Vault API. you should be able to install the Vault SDK from this folder if you have Vault installed:
C:\Program Files\Autodesk\Vault Basic 2020\SDK
I recommend you add a reference to the EdmSecurity dll from you inventor Bin file (C:\Program Files\Autodesk\Inventor 2020\Bin\Connectivity.InventorAddin.EdmAddin.dll)
then you should be able to write something like this :
using Autodesk.Connectivity.WebServices;
using Autodesk.Connectivity.WebServicesTools;
using Autodesk.DataManagement.Client.Framework.Vault.Currency.Properties;
using Connectivity.InventorAddin.EdmAddin;
using GenikAddin.DataControl;
using System;
using System.IO;
using VDF = Autodesk.DataManagement.Client.Framework;
//Code structure is not functional, just wanted to show which library i am using
//Use Inventor Vault Addin connection
EdmSecurity edmSecurity = EdmSecurity.Instance;
if (!edmSecurity.IsSignedIn())
{
edmSecurity.OnLoginButtonExecute(true); //simulate login button being pressed
}
if (edmSecurity.VaultConnection is VDF.Vault.Currency.Connections.Connection connection)
{
// DocumentPath would be your file you want to undo check out
string vaultpath = DocumentPath;
string root = System.IO.Path.GetDirectoryName(edmSecurity.InventorApp.DesignProjectManager.ActiveDesignProject.FullFileName);
//replace PC Workspace path to become Vault Root
vaultpath = vaultpath.Replace(root, "$");
//vault uses forward slash (/) as separator instead of Windows backslash (\)
vaultpath = vaultpath.Replace(System.IO.Path.DirectorySeparatorChar, '/');
//Find latest version of the file in the vault
Autodesk.Connectivity.WebServices.File[] file = connection.WebServiceManager.DocumentService.FindLatestFilesByPaths(filepath);
if (file[0].Id == -1)
{
//File Was not found
return false;
}
//Create a fileIteration
VDF.Vault.Currency.Entities.FileIteration fileIteration = new VDF.Vault.Currency.Entities.FileIteration(connection, file[0]);
}
From there I would try
connection.WebServiceManager.DocumentService.UndoCheckoutFile(fileIteration.EntityMasterId);