I use following iLogic-Code to open Drawing directly from Vault:
AddReference "Autodesk.Connectivity.WebServices.dll"
Imports ACW = Autodesk.Connectivity.WebServices
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
AddReference "Autodesk.DataManagement.Client.Framework.dll"
Imports VDF = Autodesk.DataManagement.Client.Framework
AddReference "Connectivity.Application.VaultBase.dll"
Imports VB = Connectivity.Application.VaultBase
Public Class ThisRule
Sub Main()
Dim oApp As Inventor.Application = ThisApplication
Dim oDoc As Document = ThisDoc.Document
If TypeOf ThisDoc.Document Is AssemblyDocument Then
If ThisDoc.Document.SelectSet.Count > 0 Then
oDoc = ThisDoc.Document.SelectSet(1).Definition.Document
End If
End If
Dim docfullfilename As String = oDoc.FullFileName
Dim docfilename As String = RPointToBackSlash(oDoc.FullFileName)
'Alle Zeichnungen aus dem Vault abrufen
'Auf Vault-Connection zugreifen und ggf. rausgehen
Dim mVltCon As VDF.Vault.Currency.Connections.Connection = VB.ConnectionManager.Instance.Connection
If mVltCon Is Nothing Then Exit Sub
'Auf ACW-PropertyDefininition Status zugreifen
Dim filePropDefs As ACW.PropDef() = mVltCon.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
Dim ACWNamePropDef As ACW.PropDef
For Each def As ACW.PropDef In filePropDefs
If def.DispName = "Name" Then
ACWNamePropDef = def
Exit For
End If
Next def
'Suchoptionen festlegen
Dim namesucheoptionen As New ACW.SrchCond() With { _
.PropDefId = ACWNamePropDef.Id, _
.PropTyp = ACW.PropertySearchType.SingleProperty, _
.SrchOper = 1, _
.SrchRule = ACW.SearchRuleType.Must, _
.SrchTxt = docfilename & " idw" _
}
Dim bookmark As String = String.Empty
Dim status As ACW.SrchStatus = Nothing
Dim results As ACW.File() = mVltCon.WebServiceManager.DocumentService.FindFilesBySearchConditions(New ACW.SrchCond() {namesucheoptionen }, Nothing, Nothing, False, True, bookmark, status)
Dim settings As New VDF.Vault.Settings.AcquireFilesSettings(mVltCon)
If results Is Nothing Then
MessageBox.Show("Zu dem Dokument " & docfilename & " ist keine Zeichnung im Vault vorhanden.", "Info")
Else
For Each res In results
Dim oFileIteration As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(mVltCon, res)
settings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeRelatedDocumentation = True
settings.OptionsRelationshipGathering.FileRelationshipSettings.VersionGatheringOption = VDF.Vault.Currency.VersionGatheringOption.Latest
settings.AddFileToAcquire(oFileIteration, VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download)
Next
End If
Dim aquiresults As VDF.Vault.Results.AcquireFilesResults = mVltCon.FileManager.AcquireFiles(settings)
'Alle heruntergeladenen idw's in Liste
Dim idwList As New ArrayList
For Each aquiresult As VDF.Vault.Results.FileAcquisitionResult In aquiresults.FileResults
Dim aquiresultpath As String = aquiresult.LocalPath.FullPath
If UCase(aquiresultpath).Contains(".IDW") Then
idwList.Add(aquiresultpath)
End If
Next
'idw's öffnen
For Each idw As String In idwList
oApp.Documents.Open(idw, True)
Next
End Sub
Function RPointToBackSlash(ByVal strText As String) As String
strText = Left(strText, InStrRev(strText, ".") - 1)
RPointToBackSlash = Right(strText, Len(strText) - InStrRev(strText, "\"))
End Function
End Class
Maybe you have to replace the "Name" in the line <If def.DispName = "Name" Then>. This is the filename-Property in Vault and should match to yours.