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: 

Export Items and Boms

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
iCymonkEEy
1595 Views, 7 Replies

Export Items and Boms

Hi,

I am currently trying to export itmes with their BOMs via the Vault API, the export should be a .csv or be in a own SQL database. Any ideas how i should do that ?

I dont have alot of experience with this Vault API.

 

Greets from Italy

7 REPLIES 7
Message 2 of 8
Redmond.D
in reply to: iCymonkEEy

The Vault client has an export command which allows you to export the BOM to a .csv.  You want to perform that operation at the API level, correct?

 

The PackageService is what you want to use.  Here is the basic list of functions:

  1. Call GetItemsAndBOMsFromItemIds to convert your items to the PkgItem format. 
  2. Then you create your MapPair objects.  The 'ToID" field is the column (zero-indexed) in the CSV file.  The FromID is the ID of the Vault property you want to show in that column.
  3. Call DownloadPackage to create the CSV file.

 

Here is some old code I was able to dig up.  It should still work in Vault 2013.

 

    PkgItemsAndBOM pkgBom = packageSvc.GetItemsAndBOMsFromItemIds(

  new long[] { item.Id });

 

    MapPair levelPair = new MapPair();

    levelPair.ToID = 0;

    levelPair.ToName = "Level";

    levelPair.FromID = -1000;

 

    MapPair numberPair = new MapPair();

    numberPair.ToID = 1;

    numberPair.ToName = "Number";

    numberPair.FromID = -60;

 

    MapPair typePair = new MapPair();

    typePair.ToID = 2;

    typePair.ToName = "Type";

    typePair.FromID = -62;

    byte[] contents;

 

    packageSvc.DownloadPackage(pkgBom.PkgItemArray, pkgBom.PkgBOM, FileFormat.CSV_LEVEL, new MapPair[] { levelPair, numberPair, typePair }, out contents);



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 3 of 8
iCymonkEEy
in reply to: Redmond.D

Yea,

that is more or less the same solution i found also. But my next problem seems abit more tricky.

Is it possible to add by yourself over the importfunction of the packageservice to add the detailID ?

I think that wont work with a lot of trouble.

 

And how do i get all propertydefinitions from the items ?

Message 4 of 8
Redmond.D
in reply to: iCymonkEEy

So it sounds like you want to use import to set the Detail ID.  I don't believe you can do that with the import feature.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 5 of 8
mario.lung
in reply to: Redmond.D

Hey,

 

when the file is create, where is it then.

 

i cannot find it local and also not in the vault space?

 

i have Vault 2015 

 

thx for help

 

Mario

Message 6 of 8

Hey,

 

i guess you use the function mentioned above: packageSvc.DownloadPackage(..., out content) .

The file gets created and written as byte Array. In this case its written to the variable called "content",  so its currently only in the memory.

You can create the file and save it to  your hard disk by using a FileWriter.

 

System.IO.File.WriteAllBytes("Package.csv", content);

 

hope it helps

Manuel

coolOrange
www.coolOrange.com
––––––––––––––––––
Please mark this response as "Accept as Solution" if it answers your question.
If you have found any post to be helpful, even if it's not a direct solution, then please provide that author kudos.


Message 7 of 8
Oltra
in reply to: Redmond.D

Hello @Redmond.D 

I'm trying to use the "ToID"  on MapPair (as said in the SDK 2019 docs) but it seems not to work at all.

ID valueMeaning
-510Owner Name
-520File Name
-530Quantity
-540Detail ID
-1000BOM Indicator (Level)
-1001BOM Structure (Parent)

 

Using this, won't work:

$MapInfo[0].ToID = 0
$MapInfo[0].ToName = "Level"
$MapInfo[0].FromID = -1000

 

In the other hand, I found a post that uses this kind of property mapping , and this one works

$MapInfo[0].ToID = 0
$MapInfo[0].FromName = "BOMIndicator-41FF056B-8EEF-47E2-8F9E-490BC0C52C71"
$MapInfo[0].ToName = "LEVEL"

 

Am I doing something wrong?

Where can I find the equivalent for "BOMIndicator-41FF056B-8EEF-47E2-8F9E-490BC0C52C71" but for PARENT ??

 

Many thanks in advance

Regards

 

Message 8 of 8
Oltra
in reply to: Oltra

@Redmond.D 

Sorry, ignore this part:

"Where can I find the equivalent for "BOMIndicator-41FF056B-8EEF-47E2-8F9E-490BC0C52C71" but for PARENT ??"

 

 

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

Post to forums  

Autodesk Design & Make Report