iLogic Get file from Vault Basic

iLogic Get file from Vault Basic

Nejc.Leban
Advocate Advocate
676 Views
2 Replies
Message 1 of 3

iLogic Get file from Vault Basic

Nejc.Leban
Advocate
Advocate

Hello everyone.

I know there are some similar topics about this already, but they're either old/outdated or don't quite get me what I need.

Our company is currently using Inventor Pro 2024 and Vault Basic 2024. I would like to create an iLogic rule to place a component (either ipt or iam) into an assembly.

It works fine when the component exists locally. I tried placing the component with

iLogicVault.GetFileByFullFilePath("$/Workplace/Designs/10831/10831-00-001-01.ipt")

, but it doesn't work with Vault Basic, so I'm looking for other solutions if there are any simple ones, like the one in the snippets.

 

A thing I noticed is, when trying to replace a component:

Component.Replace("S1325-03-000-00:1", "C:\Workplace\Designs\10831\10831-00-001-01.ipt", False)

If the replacement component doesn't exist locally, it gets it from Vault automatically.

Now why is that possible, while iLogicVault.GetFileByFullFilePath("$/") is limited to Vault Pro?

 

Any help is greatly appreciated.

 

Kind regards,

Nejc

 

0 Likes
Accepted solutions (1)
677 Views
2 Replies
Replies (2)
Message 2 of 3

firelinsgs
Enthusiast
Enthusiast
Accepted solution

Hi Nejc,

You need to use Vault SDK kit. (Autodesk.Connectivity.WebServices.dll and son.. )

 

Example: 

 

AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
AddReference "Autodesk.DataManagement.Client.Framework.dll"
AddReference "Autodesk.Connectivity.WebServices.dll"

Imports VDF = Autodesk.DataManagement.Client.Framework
Imports ACW = Autodesk.Connectivity.WebServices
Imports System.Linq

Sub Main()

    ' Configuration
    Dim localPath As String = "C:\YourVaultWorkspace\Designs\Project1\Component.ipt"
    Dim fileName As String = "Component.ipt"
    Dim occurrenceName As String = "PlacedComponent_01"

    Dim server As String = "YourServerName"
    Dim vault As String = "YourVaultName"
    Dim user As String = "YourUsername"
    Dim pass As String = "YourPassword"

    Dim asmDoc As AssemblyDocument = TryCast(ThisApplication.ActiveDocument, AssemblyDocument)
    If asmDoc Is Nothing Then
        MessageBox.Show("Run this rule from an assembly document.")
        Exit Sub
    End If

    ' Login to Vault
    Dim login = VDF.Vault.Library.ConnectionManager.LogIn(
        server,
        vault,
        user,
        pass,
        VDF.Vault.Currency.Connections.AuthenticationFlags.Standard,
        Nothing
    )

    If Not login.Success Then
        MessageBox.Show("Vault login failed.")
        Exit Sub
    End If

    Dim conn = login.Connection

    Try
        Dim propDefs = conn.WebServiceManager.PropertyService.
            GetPropertyDefinitionsByEntityClassId("FILE")

        Dim nameProp = propDefs.FirstOrDefault(Function(p) p.SysName = "Name")
        If nameProp Is Nothing Then
            MessageBox.Show("Name property not found.")
            Exit Sub
        End If

        Dim cond(0) As ACW.SrchCond
        cond(0) = New ACW.SrchCond With {
            .PropDefId = nameProp.Id,
            .PropTyp = ACW.PropertySearchType.SingleProperty,
            .SrchOper = 3,
            .SrchRule = ACW.SearchRuleType.Must,
            .SrchTxt = fileName
        }

        Dim bookmark As String = ""
        Dim status As ACW.SrchStatus = Nothing

        Dim files = conn.WebServiceManager.DocumentService.
            FindFilesBySearchConditions(cond, Nothing, Nothing, False, True, bookmark, status)

        If files Is Nothing OrElse files.Length = 0 Then
            MessageBox.Show("File not found in Vault.")
            Exit Sub
        End If

        Dim fileIter As New VDF.Vault.Currency.Entities.FileIteration(conn, files(0))

        ' Download file
        Dim settings As New VDF.Vault.Settings.AcquireFilesSettings(conn)
        settings.AddFileToAcquire(fileIter,
            VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download)

        conn.FileManager.AcquireFiles(settings)

        If Not IO.File.Exists(localPath) Then
            MessageBox.Show("Downloaded file not found at expected path.")
            Exit Sub
        End If

        Components.Add(occurrenceName, localPath)

    Catch ex As Exception
        MessageBox.Show("Vault error: " & ex.Message)
    Finally
        If conn IsNot Nothing Then
            VDF.Vault.Library.ConnectionManager.LogOut(conn)
        End If
    End Try

End Sub

 

Message 3 of 3

Nejc.Leban
Advocate
Advocate

Hi @firelinsgs,

 

I appreciate your reply. I was hoping for a simpler solution, as I’ve already seen the one you posted in another thread, but it seemed a bit overcomplicated.

I'll wait a bit to see if anyone has an simpler solution, otherwise I'll accept yours.

 

Kind regards,

 

0 Likes