Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Checking in and out a file

19 REPLIES 19
SOLVED
Reply
Message 1 of 20
Anonymous
8035 Views, 19 Replies

Checking in and out a file

Since the subject line of this post seams to have been changed I have re submitted the post.

 

I need to check in and out a csv file from vault regualarly for updating but i am having great dificulty getting any of the code from various places including Doug Redmonds to work. I am getting a bit frustrated as I am wasting a lot of time.

This is for vault 2014 and using VB.net

 

The complete code to log in and out a single file would be very helpfull.

 

Thanks Malcolm

19 REPLIES 19
Message 2 of 20
wayne.brill
in reply to: Anonymous

Hi Malcolm,

 

To download and checkout files use an OR statement with the AcquireFilesSettings.AcquisitionOption. I updated this function in this SDK example to test:

"C:\Program Files (x86)\Autodesk\Autodesk Vault 2014 SDK\VS10\VB\VaultBrowserSample"

 

 

PrivateSharedSub downloadFile(connection As VDF.Vault.Currency.Connections.Connection, file As VDF.Vault.Currency.Entities.FileIteration, folderPath AsString)

       

Dim settings AsNew VDF.Vault.Settings.AcquireFilesSettings(connection)

       

'wB added

        settings.DefaultAcquisitionOption = VDF.Vault.Settings.

AcquireFilesSettings.AcquisitionOption.Checkout Or

           VDF.Vault.Settings.

AcquireFilesSettings.AcquisitionOption.Download

       

'wB end added

        settings.AddEntityToAcquire(file)

        settings.LocalPath =

New VDF.Currency.FolderPathAbsolute(folderPath)

        connection.FileManager.AcquireFiles(settings)

   

EndSub

 

 

I will test using CheckinFile() and upload my project.

 

Can you tell me more about the errors you are getting?

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 3 of 20
Anonymous
in reply to: wayne.brill

Hi Wayne thanks for the reply, i have been trying similar code already but I can't pass the correct information for the 

FileIteration? I have sent both the calling part of my code and the GetFile sub.

 

        Dim conditions As SrchCond()
        ReDim conditions(0)

        Dim lCode As Long = 1
        Dim Defs As PropDef() = serviceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")
        Dim Prop As PropDef = Nothing

        For Each def As PropDef In Defs
            If def.DispName = "File Name" Then
                Prop = def
            End If
        Next def

        Dim searchCondition As SrchCond = New SrchCond()
        searchCondition.PropDefId = Prop.Id
        searchCondition.PropTyp = PropertySearchType.SingleProperty
        searchCondition.SrchOper = lCode
        searchCondition.SrchTxt = "12345 Testing XXXX.csv"

        conditions(0) = searchCondition

        ' search for files
        Dim FileList As List(Of Autodesk.Connectivity.WebServices.File) = New List(Of Autodesk.Connectivity.WebServices.File)()
        Dim sBookmark As String = String.Empty
        Dim Status As SrchStatus = Nothing

        While (Status Is Nothing OrElse FileList.Count < Status.TotalHits)

            Dim files As Autodesk.Connectivity.WebServices.File() = serviceManager.DocumentService.FindFilesBySearchConditions( _
                conditions, Nothing, Nothing, True, True, sBookmark, Status)

            If (Not files Is Nothing) Then
                FileList.AddRange(files)
            End If
        End While

        'For I = 1 To FileList.Count
        '    Vault.GetFile(Conn, FileList.Item(I), "C:\Vault\SMI Projects Data")
        'Next

 

 

Public Sub GetFile(ByVal connection As oVDF.Vault.Currency.Connections.Connection, ByVal file As oVDF.Vault.Currency.Entities.FileIteration, ByVal folderPath As String)

        Dim settings As oVDF.Vault.Settings.AcquireFilesSettings = New oVDF.Vault.Settings.AcquireFilesSettings(connection)

        settings.DefaultAcquisitionOption = oVDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Checkout Or _
                oVDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download

        ' settings.DefaultAcquisitionOption = oVDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download
        settings.AddEntityToAcquire(file)
        settings.LocalPath = New oVDF.Currency.FolderPathAbsolute(folderPath)

        connection.FileManager.AcquireFiles(settings)
    End Sub

 

 

Thanks Malcolm

Message 4 of 20
scottmoyse
in reply to: wayne.brill

Wayne

 

As a matter of interest, I'm wondering how you managed to get the colours to copy across into the code window within this post?


Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature


Design & Manufacturing Technical Services Manager at Cadpro New Zealand

Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project

Message 5 of 20
scottmoyse
in reply to: wayne.brill


@wayne.brill wrote:

Hi Malcolm,

 

To download and checkout files use an OR statement with the AcquireFilesSettings.AcquisitionOption. 


Does using the OR statement mean it Both Checks Out & downloads the file? Whereas if it only said Checkout it wouldn't download the file?


Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature


Design & Manufacturing Technical Services Manager at Cadpro New Zealand

Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project

Message 6 of 20
wayne.brill
in reply to: Anonymous

Hi Malcom,

 

I have a zip file with an example that will Check out, download and Check in a file. It is based on this SDK sample:

C:\Program Files (x86)\Autodesk\Autodesk Vault 2014 SDK\VS10\VB\VaultList

 

I was unable to attach it when I tried to post my reply. I went ahead and created this blog post. Please get it from there: http://adndevblog.typepad.com/manufacturing/2013/06/checkout-checkin-a-file-in-vault-2014.html

 

 

It has two new buttons. One does the checkout and download and the other does the CheckIn. They both use a function that does the search for a file named "12345 Testing XXXX.csv". That function returns a FileIteration object. I used your code in that function to do the search. (with some updates to get the declarations to work).

 

Here is an excerpt:

 

Dim oFileIteration As VDF.Vault.Currency.Entities.FileIteration = New VDF.Vault.Currency.Entities.FileIteration(connection, FileList(0))

       

Return oFileIteration

 

Let me know if it works for you. You will need to fix the references to the Vault dlls. (in a directory similar to this:

C:\Program Files (x86)\Autodesk\Autodesk Vault 2014 SDK\bin)

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 7 of 20
wayne.brill
in reply to: scottmoyse

Hi Scott,

 

That is what happens in my tests. If I only use Checkout the file is checked out but it is not downloaded. If I just use Download then the file is downloaded but not checked out. Please let me know if your results are different.

 

Thanks,

Wayne

 

 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 8 of 20
wayne.brill
in reply to: scottmoyse

Hi Scott,

 

I am just copying and pasting from Visual Studio. Not sure what is special about it that allows the colors to show up.

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 9 of 20
scottmoyse
in reply to: wayne.brill

Ok, it looks like you are using Internet Explorer and just pasting it directly into the message window, rather than using the insert code tool.

 

When I paste it in with Chrome (haven't tested Firefox), it doesn't bring over any formatting (Colour or font) or indentations.

 

Thanks for clarifying.


Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature


Design & Manufacturing Technical Services Manager at Cadpro New Zealand

Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project

Message 10 of 20
scottmoyse
in reply to: scottmoyse

ok it doesn't work in Firefox either. Sneaky Microsoft, just when you write off their browser, you discover something like this.


Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature


Design & Manufacturing Technical Services Manager at Cadpro New Zealand

Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project

Message 11 of 20
scottmoyse
in reply to: wayne.brill

Wayne,

 

Thanks heaps for helping out here, that worked perfectly for us with some minor tweaking. Very relieved.

 

 


Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature


Design & Manufacturing Technical Services Manager at Cadpro New Zealand

Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project

Message 12 of 20
scottmoyse
in reply to: wayne.brill

its strange that its OR instead of AND. normally with OR operators in conditions the code moves on if the first condition is true. So although this isn't a condition it seems like a strange way of setting those options. Is there some other logic here that I'm missing? Just trying to understand it, rather than take it for granted.

 


Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature


Design & Manufacturing Technical Services Manager at Cadpro New Zealand

Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project

Message 13 of 20
minkd
in reply to: scottmoyse

You are confusing a logical OR "||" with a bitwise OR "|".

But that's the C, C++, C# and Java way to do it - why VB would use "OR" for both is anybody's guess.

 

-Dave



Dave Mink
Fusion Lifecycle
Autodesk, Inc.
Message 14 of 20
Anonymous
in reply to: wayne.brill

Hi Wayne thanks for the code it works and has saved me a lot of time and frustration.

 

Malcolm

Message 15 of 20
jlane
in reply to: Anonymous

Hi there, I'm completely new to Vault customization (and C#), and am becoming familiar with the SDK examples for C#.

 

What I'm trying to automate with a console app (no need for the Vault Client to be open) is something fairly simple:

1. Connect & Login to Vault with the users Windows login credentials

2. Get the latest version of a specific Navisworks fileset (.nwf) and all it's children.  This .nwf file always exists and has a static path, so no need to search.

3. Check out a specific Naviswoks .nwd.  This .nwd file always exists and has a static path, so no need to search.

4. Publish the .nwf file and overwrite the .nwd file.

5. Check in the .nwd file

 

Can someone help me with the C# code for this?  I have step 4 working fine using the Navisworks API.  Just need to take care of the Vault side.

 

Thx!

Message 16 of 20
c.rp.henderson
in reply to: jlane

I get this error when I run the code. What do I need to change?

Vault macro error.JPG



Craig Henderson
Inventor Pro 2018.3.3, Build 284 / Vault Pro 2018 / Visual Studio 2012 / Excel 2013
Message 17 of 20
Boorda
in reply to: c.rp.henderson

The error indicates that the application cannot find the Autodesk.DataManagement.Client.Framework.Vault assembly that should be referenced by the project.

 

In the Solution Explorer in the VaultList project expand the References node.

If you see little yellow triangles like below then you need to delete and re-add the references to those Vault .dll files.

They are in the C:\Program Files (x86)\Autodesk\Autodesk Vault <year version> SDK\ folder assuming you installed the Vault SDK.

 

Bad References.png

 

After re-adding your references should look like this and the error should be corrected.

Good References.png


Automation is key!
Message 18 of 20
c.rp.henderson
in reply to: Boorda

I'm not able to open the project in VS2012 Express. In the solution explorer it says VaultList (load failed). Any ideas why?

I think when I opened it up for the first time it say some elements were not loaded properly.



Craig Henderson
Inventor Pro 2018.3.3, Build 284 / Vault Pro 2018 / Visual Studio 2012 / Excel 2013
Message 19 of 20
Boorda
in reply to: c.rp.henderson

Unfortunately that could be anything.

Can you explain any errors you are receiving?

Post any screen shots of the errors?

 

If you send me a PM maybe we could set it up so I could remote into your machine and assist you.

 

-Addam


Automation is key!
Message 20 of 20
jaka73LU2
in reply to: wayne.brill

Hi I want to do the same thing in Inventor 2014. I am trying to make an AddIn in Inventor, that can CheckIn And Check Out a drawing or model.

I used your code and I am having trouble connecting to the Vault Server. I am geting this error:

jaka73LU2_0-1684321662617.png

Error is on this line:

' For demonstration purposes, the information is hard-coded.
Dim results As VDF.Vault.Results.LogInResult = VDF.Vault.Library.ConnectionManager.LogIn("localhost", "Vault", "Administrator", "", VDF.Vault.Currency.Connections.AuthenticationFlags.Standard, Nothing)

 

I am guessing I am having trouble connecting to our server for some reason?

For localHost I used an IP that IT gave me and for Vault the server name.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report