Using Vault API to Upload Document Hierarchy

By Barbara Han

Adding a single file to Vault through API is not complex. The complex part is to have uploaded files associated to each other as the hierarchy as present as they are open in CAD software, and items can be created properly when performing ‘assign item’. To achieve this goal, you need to perform the following steps:-
1. Create a proper document hierarchy when adding files to the Vault. The parameter associations of the AddFile from DocumentService can be used for this.
2. When adding files to Vault, it’s necessary to supply valid BOM data. Documents without BOM data are promoted to ‘Document’ items, instead of ‘Part’, ‘Assembly’.
3. For part documents the BOM.CompArray should contain one element containing the following fields for "this" document – UniqueID (guid), CompTyp (Part), XRefId (-1), XRefTyp (internal).
4. For assembly documents the BOM.CompArray should include information for "this" document plus some elements for child documents. The BOMComp for child information should containt UniqueID (same as UniqueID of the corresponding document), XrefId (File.Id of document), XrefTyp (external).
5. For assembly documents the BOM.InstArray should be also filled. It should describe complete document hierarchy up to current level (children-parent relationship using indices to BOM.CompArray).
6. When populating Vault, it’’s necessary to start with leaf nodes (deepest children) and the continue with their parents and so on.
7. Other BOM fields are optional, however in real cases BOM.PropArray, BOM.SchmArray and BOM.SchmOccArray would be also filled.
 
If you use Assign Item for such documents, Vault will create assembly & part items. 
  
The sample application allows you create a hierarchy of any documents. They can be promoted to assembly & part items. You can use any files – the entire hierarchy is built programmatically.

Download HierarchyBuilder

Download DataSet
How to use:
1. Run the application.
2. Connect to Vault.
3. Use browse button to locate a Vault folder where the hierarchy should be uploaded.
4. Move the cursor to the tree view area and press RMB (right mouse button), then select Add Item.
5. Locate assembly.txt file from the sample data set (see Dataset.zip). It will add the new item to root of the tree.
6. Select assembly.txt node, then use RMB again to build a tree hierarchy of files.
7. When you're done with your hierarchy, click on the Upload button. It will add the files to the Vault.
 
Notes:
– Assumption is that files don't already exist in the Vault
– The goal of the sample is to show how to set up a "minimal" BOM when building a hierarchy
– The most important class is HierarchyItem, which handles document upload. It also builds BOM data for documents.


Comments

One response to “Using Vault API to Upload Document Hierarchy”

  1. Is there an example of how to upload the same hierarchy more than once, building upon the originally uploaded hierarchy by either adding another child node, or removing one?

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading