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
Solved! Go to Solution.
Solved by wayne.brill. Go to Solution.
Solved by wayne.brill. Go to Solution.
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
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
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.
Design & Manufacturing Technical Services Manager at Cadpro New Zealand
Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project
@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.
Design & Manufacturing Technical Services Manager at Cadpro New Zealand
Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project
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
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
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
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.
Design & Manufacturing Technical Services Manager at Cadpro New Zealand
Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project
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.
Design & Manufacturing Technical Services Manager at Cadpro New Zealand
Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project
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.
Design & Manufacturing Technical Services Manager at Cadpro New Zealand
Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project
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.
Design & Manufacturing Technical Services Manager at Cadpro New Zealand
Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project
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
Hi Wayne thanks for the code it works and has saved me a lot of time and frustration.
Malcolm
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!
I get this error when I run the code. What do I need to change?
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.
After re-adding your references should look like this and the error should be corrected.
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.
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
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:
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.