Yes this is possible. We have a similar workflow with purchased parts online cut sheets. I made a rule that pdf combines all cut sheet files for the given assembly. It uses the file search for matching stock numbers or matching folder location. Here's the function that gets the file and returns it's local path
AddReference "C:\_IPI_Vault\Inventor Configuration\iLogic\itextsharp.dll"
AddReference "System.IO"
AddReference "System.Private.Uri"
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
Imports VDF = Autodesk.DataManagement.Client.Framework
AddReference "Connectivity.Application.VaultBase.dll"
Imports VB = Connectivity.Application.VaultBase
AddReference "Autodesk.Connectivity.WebServices.dll"
Imports AWS = Autodesk.Connectivity.WebServices
Function GetFromVault(PurchasedFolder As String, StockNumber As String, FullFileName As String)
'convert file name to vault format
PurchasedFolder = PurchasedFolder.Replace("C:\_IPI_Vault", "$")
PurchasedFolder = PurchasedFolder.Replace("\", "/")
FullFileName = FullFileName.Replace("C:\_IPI_Vault", "$")
FullFileName = FullFileName.Replace("\", "/")
'get vault login
Dim mVltCon As VDF.Vault.Currency.Connections.Connection
mVltCon = VB.ConnectionManager.Instance.Connection
If mVltCon Is Nothing Then
MsgBox("Not logged in to Vault")
Exit Function
End If
Dim wsFolder As AWS.Folder
wsFolder = mVltCon.WebServiceManager.DocumentService.GetFolderByPath(PurchasedFolder)
'get search criteria
Dim filePropDefs As Autodesk.Connectivity.WebServices.PropDef() = mVltCon.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
Dim StockNumberPropDef As Integer
Dim FolderPathPropDef As Integer
Dim FileExtensionPropDef As Integer
For Each filePropDef In filePropDefs
If filePropDef.DispName = "Mfg Part Number/Stock Number"
StockNumberPropDef = filePropDef.Id
ElseIf filePropDef.DispName = "Folder Path"
FolderPathPropDef = filePropDef.Id
ElseIf filePropDef.DispName = "File Extension"
FileExtensionPropDef = filePropDef.Id
End If
Next
'set search criteria
Dim foundfiles() As AWS.File
Dim srs As New List(Of AWS.SrchSort)
Dim fIDs1 As New List(Of Long)
fIDs1.Add(wsFolder.Id)
Dim bm As String = String.Empty
Dim ss As New AWS.SrchStatus
Dim scs1 As New List(Of AWS.SrchCond)
Dim scs2 As New List(Of AWS.SrchCond)
Dim sc1 As New AWS.SrchCond
Dim sc2 As New AWS.SrchCond
With sc1
.PropDefId = FileExtensionPropDef
.SrchOper = 1
.SrchTxt = "pdf"
.PropTyp = AWS.PropertySearchType.SingleProperty
.SrchRule = AWS.SearchRuleType.Must
End With
With sc2
.PropDefId = StockNumberPropDef
.SrchOper = 1
.SrchTxt = StockNumber
.PropTyp = AWS.PropertySearchType.SingleProperty
.SrchRule = AWS.SearchRuleType.Must
End With
scs1.Add(sc1)
scs1.Add(sc2)
'pdf w/ matching stock number in purchased parts folder
foundfiles = mVltCon.WebServiceManager.DocumentService.FindFilesBySearchConditions(scs1.ToArray, srs.ToArray, fIDs1.ToArray, True, True, bm, ss)
Try
test = foundfiles.Length
Catch
scs2.Add(sc1)
Try
wsFolder = mVltCon.WebServiceManager.DocumentService.GetFolderByPath(FullFileName.Substring(0, FullFileName.LastIndexOf("/")))
Catch
MessageBox.Show(FullFileName.Substring(0, FullFileName.LastIndexOf("/")))
End Try
Dim fIDs2 As New List(Of Long)
fIDs2.Add(wsFolder.Id)
'pdf w/ matching folder location
foundfiles = mVltCon.WebServiceManager.DocumentService.FindFilesBySearchConditions(scs2.ToArray, srs.ToArray, fIDs2.ToArray, True, True, bm, ss)
Try
test = foundfiles.Length
Catch
Logger.Info("PDF NOT IN VAULT - " & StockNumber)
Return ""
End Try
End Try
'get pdf
Dim oSettings As VDF.Vault.Settings.AcquireFilesSettings
oSettings = New VDF.Vault.Settings.AcquireFilesSettings(mVltCon, False)
Dim fileToDownload As VDF.Vault.Currency.Entities.FileIteration
fileToDownload = New VDF.Vault.Currency.Entities.FileIteration(mVltCon, foundfiles(0))
oSettings.AddFileToAcquire(fileToDownload, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download)
Dim oAcquireFilesResults As VDF.Vault.Results.AcquireFilesResults
oSettings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren = True
oSettings.OptionsRelationshipGathering.FileRelationshipSettings.RecurseChildren = True
oSettings.OptionsRelationshipGathering.FileRelationshipSettings.VersionGatheringOption = VDF.Vault.Currency.VersionGatheringOption.Latest
oSettings.OptionsResolution.OverwriteOption = VDF.Vault.Settings.AcquireFilesSettings.AcquireFileResolutionOptions.OverwriteOptions.NoOverwrite
oAcquireFilesResults = mVltCon.FileManager.AcquireFiles(oSettings)
Dim filefolder As AWS.Folder = mVltCon.WebServiceManager.DocumentService.GetFolderById(foundfiles(0).FolderId)
Dim FilePath As String = filefolder.FullName & "\" & foundfiles(0).Name
FilePath = FilePath.Replace("$", "C:/_IPI_Vault")
FilePath = FilePath.Replace("\", "/")
Return FilePath
End Function