Hi
Can somebody suggest how we can achive the rename file wizard functionality of Vault 2014 explorer using API.
i want file to be renamed and file properties like PartNumber get updated automatically.
thanks
Hi mnav,
Add a handler for checkIn event (GetRestriction, Pre or Post based on your requirement)
AddHandler DocumentService.CheckinFileEvents.GetRestrictions, AddressOf CheckinFileCheck
In that handler event specify the new file name
Private Sub CheckinFileCheck(ByVal sender As Object, ByVal e As CheckinFileCommandEventArgs)
e.NewFileName = "New file name"
End Sub
For updating properties if it is going to be vault properties then you have to
If you want to update Inventor file properties then you have to
Regards,
Balaji A
Hi BalaJi
Thanks for your reply.
we can provide new name on chekin anyway. what is the point of using checkin event.
For bulk file rename this will not work.
thanks
To manipulate any properties you need to use the Checkout/Checkmethods as described by BalaJi(Just the way it is :)...
To do a batch rename you would need to do something like so..
Dim fileItem As Vault.Currency.Entities.FileIteration = Nothing
Dim oSettings As Vault.Settings.AcquireFilesSettings = New Vault.Settings.AcquireFilesSettings(m_conn)
'Going to Checkout and download
oSettings.DefaultAcquisitionOption = Vault.Settings.AcquireFilesSettings.AcquisitionOption.Checkout Or Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download
oSettings.AddEntityToAcquire(fileItem)
'set the path to the working folder
oSettings.LocalPath = m_conn.WorkingFoldersManager.GetWorkingFolder(fileItem) 'fldrPath
'Do the download
m_conn.FileManager.AcquireFiles(oSettings)
'Checkin the File
m_conn.FileManager.CheckinFile(fileItem, "Modified", False, New ACW.FileAssocParam() {}, Nothing, False, {Your New FileNAme as String}, ACW.FileClassification.None, False, filePathAbs)
This doesn't seem to be working.
The checkinFile function work until I enter a parameter for checkin name. When I do that it will generate an exception (exception 0) with no extra detail about the error.
This code generate error: mainconnection.FileManager.CheckinFile(oFileIteration, Nothing, False, New Autodesk.Connectivity.WebServices.FileAssocParam() {}, Nothing, False, "NewFileName.IPT", Autodesk.Connectivity.WebServices.FileClassification.None, False, Nothing)
But this one works:
mainconnection.FileManager.CheckinFile(oFileIteration, Nothing, False, New Autodesk.Connectivity.WebServices.FileAssocParam() {}, Nothing, False, nothing, Autodesk.Connectivity.WebServices.FileClassification.None, False, Nothing)
Ok so the previous code is mising one line.. after the download make you changes like below.
'Do the download
m_conn.FileManager.AcquireFiles(oSettings)
'Change The properties
Change_Prop(fileItem, m_conn)
'Checkin the File
m_conn.FileManager.CheckinFile(fil...
This should help you solve your issue
http://justonesandzeros.typepad.com/blog/2015/02/another-way-to-update-properties.html
Change_Prop(fileItem, m_conn) seems to be a custom function. I didn't find this function is Vault SDK documentation.
The closed that I found was
Sub UpdateFileProperties( _
ByVal file As File, _
ByVal props As System.Collections.Generic.Dictionary(Of PropDef,Object) _
)
As the second parameter, we have to specify what properties shoudl get updated.
Can you be more precise about the funvtion or if you have developed the change_prop, you can post it please.
Thanks
Change_Prop(file As Vault.Currency.Entities.FileIteration, m_conn As Vault.Currency.Connections.Connection) - is a custom action, the idea is that you follow the steps as previously defined and then create your custom change.
what every your script is it needs to run something like this to make the change
Dim propDef As Vault.Currency.Properties.PropertyDefinition
Dim oldprop As String
returnvalue = oldprop.Value.ToString()
'Change the Property
m_conn.WebServiceManager.DocumentService.UpdateFileProperties(New Long() {file.EntityMasterId}, New Long() {propDef.Id}, New String() {returnvalue})
Let me know if this works
What I need to do, as the tile of this page suggests, is renaming vault files. And I don't know what properties I should modify to to rename the file in vault.
Do you have any real code that rename files in the vault?
This exmaple should have everything you need..
I haven't tested this, but it should be something like this...
I use the Public Function getFileIteration _ from the previous link
Dim fileItem As Vault.Currency.Entities.FileIteration = Nothing
fileItem = getFileIteration("Name of Your File", m_conn)
Dim fldrPath As Framework.Currency.FolderPathAbsolute = m_conn.WorkingFoldersManager.GetWorkingFolder(fileItem)
Dim filePath As String = Path.Combine(fldrPath.ToString(), fileItem.EntityName)
Dim filePathAbs As Framework.Currency.FilePathAbsolute = New Framework.Currency.FilePathAbsolute(filePath)
' Checkin substituting NewFileName As String
m_conn.FileManager.CheckinFile(fileItem, "Modified", False, New ACW.FileAssocParam() {}, Nothing, False, newFileName As String, ACW.FileClassification.None, False, filePathAbs)
Ok.
I think I figured out what I was missing!
I had the comment argument as null. Apparently, if we are checking in the file with a new name, there should be a comment for it. For regular checking in, comment is no necessary, but for renaming having a comment is mandatory.