- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is it possible to open a file from the Vault using iLogic? I want to batch process a large group of files, but the examples I am finding all show how to do it based on grabbing a file from the local workspace and I need to get the latest file from the Vault.
Using Vault Basic 2015 now, shortly upgrading to Vault Workspace (not sure if that affects anything with this). Specifically I am trying to tweak this script to search for a list of files from the Vault and loop through them:
http://www.mastergraphics.com/wordpress/2014/batch-processing-with-ilogic/
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I solved a similar problem and found that using iLogic can not access to the Vault. You must use .net.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@Richard.MM Hi, could you post your solution in .net? I'm also interested in this. Would be great to see a example.
Please kudo if this post was helpfull
Please accept as solution if your problem was solved
Inventor 2014 SP2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Here is the code that download drawing from the vault and open it.
But you'll have to modify it for his own use.
VB.net:
Imports Autodesk.DataManagement.Client.Framework.Vault
Imports Autodesk.Connectivity.WebServicesTools
Imports VDF = Autodesk.DataManagement.Client.Framework
Imports ACW = Autodesk.Connectivity.WebServices
Imports System.Collections
Imports System.Windows.Forms
Public Class Otevr_zVault
Dim fileIters As System.Collections.Generic.ICollection(Of VDF.Vault.Currency.Entities.FileIteration)
Public Shared kontrola As String
Public Sub stahni_vykr()
Dim results1 As VDF.Vault.Results.LogInResult = VDF.Vault.Library.ConnectionManager.LogIn("xxx", "xxxx", "Administrator", "", VDF.Vault.Currency.Connections.AuthenticationFlags.WindowsAuthentication, Nothing)
If Not results1.Success Then
MsgBox("Error1")
End If
Dim connection As VDF.Vault.Currency.Connections.Connection = Nothing
connection = results1.Connection
Dim m_inventorApp As Inventor.Application = Nothing
' get running Inventor
Try
m_inventorApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
Catch ex As Exception
MsgBox("Error2")
End Try
Try
If m_inventorApp Is Nothing Then
MsgBox("Error3")
Return
End If
Catch
End Try
m_inventorApp.Visible = True
Dim oDoc As Inventor.Document
oDoc = m_inventorApp.ActiveDocument
Dim fullfilename1 As String = oDoc.FullFileName
Dim vykr As String
If Not fullfilename1 = Nothing Then
If oDoc.DisplayName.EndsWith(".ipt") Or oDoc.DisplayName.EndsWith(".iam") Then
vykr = Microsoft.VisualBasic.Left(oDoc.DisplayName, InStrRev(oDoc.DisplayName, ".")) & "idw"
ElseIf oDoc.DisplayName.EndsWith(".idw") Then
vykr = oDoc.DisplayName
Else
vykr = oDoc.DisplayName & ".idw"
End If
Else
MessageBox.Show("Error4")
Return
End If
Dim oFolder3 As String = Microsoft.VisualBasic.Left(fullfilename1, InStrRev(fullfilename1, "\") - 1)
Dim oFolder2 As String = Microsoft.VisualBasic.Left(oFolder3, InStrRev(oFolder3, "\"))
If fullfilename1 = Nothing Then
MsgBox("Error5")
Return
End If
Dim fullfilename As String = oFolder2 & "Drawings\" & vykr
Try
Dim oFileIteration As VDF.Vault.Currency.Entities.FileIteration = Nothing
Try
'convert local path string to vault format
Dim VaultPath As String = fullfilename
If VaultPath.Contains("D:\Vault_Working\") Then
VaultPath = VaultPath.Replace("D:\Vault_Working\", "$/")
ElseIf VaultPath.Contains("E:\Vault_Working\") Then
VaultPath = VaultPath.Replace("E:\Vault_Working\", "$/")
Else
MsgBox("Error6 " + VaultPath)
Return
End If
VaultPath = VaultPath.Replace("\", "/")
Dim VaultPaths() As String = New String() {VaultPath}
Dim DocService As ACW.DocumentService
DocService = connection.WebServiceManager.DocumentService
Dim files As ACW.File() = Nothing
Try
files = DocService.FindLatestFilesByPaths(VaultPaths)
Catch
End Try
Dim file As ACW.File
file = files(0)
oFileIteration = New VDF.Vault.Currency.Entities.FileIteration(connection, file)
Catch ex As Exception
MsgBox("Error7")
End Try
If oFileIteration IsNot Nothing Then
'get settings
Dim oSettings As VDF.Vault.Settings.AcquireFilesSettings = New VDF.Vault.Settings.AcquireFilesSettings(connection)
oSettings.DefaultAcquisitionOption = VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download 'Or VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Checkout
oSettings.AddEntityToAcquire(oFileIteration)
kontrola = "NE"
connection.FileManager.AcquireFiles(oSettings)
End If
Catch ex As Exception
Dim Rodice As New Rodice
Call Rodice.GetWhereUsed()
Return
Finally
VDF.Vault.Library.ConnectionManager.LogOut(connection)
End Try
m_inventorApp.Documents.Open(fullfilename)
kontrola = Nothing
End Sub
End Class
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
These two lines are not necessary there
Dim Rodice As New Rodice
Call Rodice.GetWhereUsed()Simply delete them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
are you able to post any code that you optimized to work for you?
I have been trying so hard to get it to work for us and we can get it to work but not consistently and it requires a lot of set up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am sending the code we are using and it works.
MsgBox outputs are written in Czech language.
Public Sub GetWhereUsed(m_inventorApp_rr As Inventor.Application)
m_inventorApp = m_inventorApp_rr
m_inventorApp.Visible = True
Dim oDoc As Inventor.Document
oDoc = m_inventorApp.ActiveDocument
If m_inventorApp.ActiveDocument.DocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject Then
MessageBox.Show("Zdarec, máš otevřený výkres, akce bude přerušena", "Nespi!", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
Dim hledam As String = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) + System.IO.Path.GetExtension(oDoc.FullFileName)
Dim results As VDF.Vault.Results.LogInResult = VDF.Vault.Library.ConnectionManager.LogIn("xxxxx", "yyyyy", "zzzzz", "wwwww",
VDF.Vault.Currency.Connections.AuthenticationFlags.WindowsAuthentication,
Nothing)
If Not results.Success Then
MsgBox("Připojení k Vaultu se nezdařilo")
End If
connection = results.Connection
Dim Defss As PropDef() = connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("ITEM")
Dim Prop As PropDef = Nothing
For Each def As PropDef In Defss
If def.DispName = "Revision" Then
Prop = def
End If
Next def
Dim searchCondition As SrchCond = New SrchCond()
searchCondition.PropDefId = Prop.Id
defs = connection.WebServiceManager.PropertyService.FindPropertyDefinitionsBySystemNames("FILE", {"ClientFileName"})
srchCond.PropDefId = defs(0).Id
srchCond.PropTyp = PropertySearchType.SingleProperty
srchCond.SrchRule = SearchRuleType.Must
srchCond.SrchOper = 3
srchCond.SrchTxt = hledam
SrcConds(0) = srchCond
Try
files = connection.WebServiceManager.DocumentService.FindFilesBySearchConditions(SrcConds,
Nothing,
Nothing,
True,
True,
bookmark,
searchStatus)
Catch
MsgBox("Nemohu ziskat soubor z Vaultu")
End Try
Dim assocArray2 As FileAssocArray() = Nothing
For Each chci In files
If chci.Name = hledam Then
assocArray2 = connection.WebServiceManager.DocumentService.GetLatestFileAssociationsByMasterIds(New Long() {chci.MasterId},
FileAssociationTypeEnum.All,
True,
FileAssociationTypeEnum.None,
True,
True,
True,
True)
End If
Next
If assocArray2(0).FileAssocs Is Nothing Then
MessageBox.Show("Nemohu najít žádný výkres, zřejmě to budš muset udělat ručně!")
Return
End If
Dim vykresy(assocArray2(0).FileAssocs.Count) As String
If Not assocArray2 Is Nothing Then
For i = 0 To assocArray2(0).FileAssocs.Count - 1
If assocArray2(0).FileAssocs(i).ParFile.Name.EndsWith("idw") Then
If Not assocArray2(0).FileAssocs(i).ParFile.Name Is Nothing Then
vykresy(i) = assocArray2(0).FileAssocs(i).ParFile.Name
End If
End If
Next
Else
MessageBox.Show("Nemohu najít žádný výkres.")
Exit Sub
End If
Dim arr As New ArrayList
For i As Integer = 0 To vykresy.Length - 1
If Not arr.Contains(vykresy.GetValue(i)) Then
arr.Add(vykresy.GetValue(i))
End If
Next
vykresy = arr.ToArray(GetType(String))
Me.Show()
Dim prvni As Integer = 0
For Each sr In vykresy
prvni = prvni + 1
If Not sr Is Nothing Then
If prvni = 1 Then
Me.CheckedListBox1.Items.Add(sr, True)
Else
Me.CheckedListBox1.Items.Add(sr, False)
End If
End If
Next
TextBox1.AppendText(System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) + ".idw")
End Sub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Would this VB.NET code work with Vault Basic?
We are currently on 2019 versions, but upgrading soon.
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I don't know, it was originally made for Vault professional 2017. Now we have switched to Professional 2022 and after recompiling it into new libraries it still works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Do you have a solution for VBA? This is what I have available for connecting with INV2022. Is there a shift for Autodesk using VB.NET, and is VBA going to get discontinued?
Kind regards,
Rafael