Question for AAD: Checkin local files in Vault

Question for AAD: Checkin local files in Vault

Anonymous
Not applicable
722 Views
3 Replies
Message 1 of 4

Question for AAD: Checkin local files in Vault

Anonymous
Not applicable

Hello,

 

I am trying to checkin local files that are not in the Vault yet. I'm using the ocde below but get an error and don't know what to do?

 

I am woriking in Inventor 2016/2017.

I found the code below online and there was no mentioning of problems.

I have a treelist with local files not in the vault yet. The user selects the file he wants to check in.

 

 

private void btnCheckIn_Click(object sender, EventArgs e)
{
IEnumerable<Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.Folder> thevaultfolders = _vaultConnection.FolderManager.GetChildFolders(_vaultConnection.FolderManager.RootFolder, true, false);
List<TreeListNode> chknodes = treeListUncheckFiles.GetAllCheckedNodes();
foreach (TreeListNode treeListNode in chknodes)
{
string flnam = treeListNode.GetDisplayText(0);
if (!System.IO.File.Exists(flnam)) continue;
string fldrnaam = Path.GetDirectoryName(flnam);
fldrnaam = GetDirnaam(fldrnaam);
Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.Folder fldr = thevaultfolders.FirstOrDefault(n => n.FullName.Equals(fldrnaam));
if (fldr == null) continue; 
Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.FileIteration fileIteration;
using (Stream sr = new FileStream(flnam, FileMode.Open, FileAccess.Read))
{
fileIteration = _vaultConnection.FileManager.AddFile(fldr, fldrnaam, "Added by CreateForce",
DateTime.Now, null, null, FileClassification.DesignDocument, false, sr);

//// THIS IS THE LINE INVENTOR CRASHES. SOMETIMES WITHOUT A WARNING.

/// AND SOMETIMES WITH THE MESSAGE:

 

File Cannot be Added. 'test.iam" cannot be added due to vault restrictions.

Restriction: You must add design files to the vault through the appropriate application to maintain correct relationship data. 

 

}
_vaultConnection.FileManager.CheckinFile(fileIteration, "Added by CreateForce", false, null, null, false,
flnam, FileClassification.None, false, new FilePathAbsolute(fldrnaam));

treeListUncheckFiles.Nodes.Remove(treeListNode);
}
}

 

How can I get this to work ?

 

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

wayne.brill
Collaborator
Collaborator

Hi Remy,

 

Currenlty adding or checking in Inventor files through the API is not supported by Autodesk. There is a large amount of meta-data that goes along with a file upload (RefId, dependencies, BOM). So, we recommend letting the CAD plug-in do the upload of CAD data. It’s the same reason Vault Explorer doesn’t let you drag and drop CAD files into Vault.

There is a ticket logged for this with Vault engineering for enabling the Vault AddIn automation.

You could also request this ability on the Vault Idea Station.
http://forums.autodesk.com/t5/Vault-IdeaStation/idb-p/2

 

http://forums.autodesk.com/t5/vault-ideas/api-access-to-vault-inventor-add-in-and-other-cad-add-ins/...

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 4

Anonymous
Not applicable

Dear Wayne,

 

Thank you for your reply, but what I don't understand is, when it is not supported to checkin files outside the vault, why do the functions

FileManager.AddFile and FileManager.CheckinFile excist ?? They clearly imply to do something they apperently do not ??

 

 

0 Likes
Message 4 of 4

wayne.brill
Collaborator
Collaborator
Accepted solution

Hi Remy,

 

Those functions can be used to add files to the Vault. Just not CAD files. (like Inventor or AutoCAD files)

 

Hope this explains.

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

0 Likes