How to create event handler for vault file download, add-in

How to create event handler for vault file download, add-in

COLINBRUSCHI
Enthusiast Enthusiast
786 Views
9 Replies
Message 1 of 10

How to create event handler for vault file download, add-in

COLINBRUSCHI
Enthusiast
Enthusiast

Hi All,

 

I've written an add-in to get out-of-date files from Vault (basic client). If the file has been locally modified, the acquire code wont overwrite the local copy. From what I can gather this behaviour can be changed by setting the PreFileAcquireEventArgs enum to "OK".

 

The SDK documentation gives the class: AcquireFilesSettings.AcquireFileExtensibilityOptions.PreFileAcquireEventArgs Class

 

and states: 

The result of the PreFileAcquireEvent. This can be set to specify how the acquire of this file should continue.

 

How does one handle the preacquire event?

 

The code to acquire as follows:

 

' Get settings 
 Dim oSettings As VDF.Vault.Settings.AcquireFilesSettings = New VDF.Vault.Settings.AcquireFilesSettings(oConnection)

'get 
oSettings.DefaultAcquisitionOption = VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download

oSettings.AddEntityToAcquire(oFileIteration)

'set the path to the working folder
        oSettings.LocalPath = fldrPath 

 oConnection.FileManager.AcquireFiles(oSettings)

 

 

 

0 Likes
787 Views
9 Replies
Replies (9)
Message 2 of 10

bradeneuropeArthur
Mentor
Mentor

you have pre and post events:

 

AddHandler DocumentService.CheckoutFileEvents.Pre, AddressOf CheckouFileCheckPre

AddHandler DocumentService.CheckoutFileEvents.Post, AddressOf CheckinFileCheckPost

with these handlers:

Private Sub CheckinFileCheckPre(ByVal sender As Object, ByVal e As CheckinFileCommandEventArgs)
'Code
end sub

Private Sub CheckinFileCheckPost(ByVal sender As Object, ByVal e As CheckinFileCommandEventArgs)
'Code
end sub

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 10

COLINBRUSCHI
Enthusiast
Enthusiast

Thanks, I'm still a bit confused though.

 

If the event is handled by: 

 

AddHandler DocumentService.DownloadFileEvents.Pre, AddressOf preAcquire

How do I access the prefileacquireeventargs, as I guessed in below code:

 

Private Sub preAcquire(ByVal sender As Object, ByVal e As AcquireFilesSettings.AcquireFileExtensibilityOptions.PreFileAcquireEventArgs)

        e.PreFileAcquisitionResult = AcquireFilesSettings.PreFileAcquisitionResult.OK

    End Sub

This obviously throws an exception since the type of e doesnt match the downloadfileevents handler

 

 

0 Likes
Message 4 of 10

bradeneuropeArthur
Mentor
Mentor

handler looks like this:

 

  Private Sub preAcquire(sender As Object, e As DownloadFileCommandEventArgs)

        End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 10

COLINBRUSCHI
Enthusiast
Enthusiast

How do you set the PreFileAcquireEventArgs from downloadfilecommandeventargs?

 

Only the following are accessible

 

Capture.JPG

0 Likes
Message 6 of 10

bradeneuropeArthur
Mentor
Mentor

with:

 

 Private Sub preAcquire(sender As Object, e As DownloadFileCommandEventArgs)
            
            e.FileIds….
        End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 7 of 10

COLINBRUSCHI
Enthusiast
Enthusiast

Sorry, still somewhat lost.

 

I've added the addhandler line to my download file sub, this should create the link to the handler just before the file is acquired, however the event handler code doesnt run.

' Get settings 
        Dim oSettings As VDF.Vault.Settings.AcquireFilesSettings = New VDF.Vault.Settings.AcquireFilesSettings(oConnection)

        'get 
        oSettings.DefaultAcquisitionOption = VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download

        oSettings.AddEntityToAcquire(oFileIteration)

        'set the path to the working folder
        oSettings.LocalPath = fldrPath 'connection.WorkingFoldersManager.GetWorkingFolder(oFileIteration)

        AddHandler DocumentService.DownloadFileEvents.Pre, AddressOf preAcquire

        'Do the download
        oConnection.FileManager.AcquireFiles(oSettings)

Do i use the fileIds in a getfilesbyIds type statement? How do I then access the PreFileAcquireEventArgs property?

0 Likes
Message 8 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support

@COLINBRUSCHI,

 

Hoping that below youtube link may be helpful.

 

https://www.youtube.com/watch?v=n9aTyhHjtJk

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 9 of 10

COLINBRUSCHI
Enthusiast
Enthusiast

It appears you can't monitor events with vault basic...

 

From SDK documentation:

Availability
This feature is not available in base Vault.  Vault Workgroup, Vault Collaboration or Vault Professional is required.
Message 10 of 10

COLINBRUSCHI
Enthusiast
Enthusiast

Well the solution wasn't to use an event, it was to configure the following option to force an overwrite:

 

oSettings.OptionsResolution.OverwriteOption = AcquireFilesSettings.AcquireFileResolutionOptions.OverwriteOptions.ForceOverwriteAll
0 Likes