How to : Pdm Api perform BOM export to csv ?

Is there a Pdm API call for the export BOM button ?

I have tried the following :

"bomView = (IEdmBomView3)aFile.GetComputedBOM(ppoRetLayout.mbsLayoutName, 0, "@", (int)EdmBomFlag.EdmBf_AsBuilt + (int)EdmBomFlag.EdmBf_ShowSelected);"

But the results are not the same as using the button in Pdm itself.

Any help appreciated,

Thanks.


Comments 1
DW
DW 2021-08-03

I used this to add each row to a "bom" object. It should not be hard to output that as a CSV.

if (layout.mbsLayoutName == "Bill of Materials")
                {
                    var bomView = file.GetComputedBOM(layout.mbsLayoutName, 0, "@", (int)EdmBomFlag.EdmBf_AsBuilt + (int)EdmBomFlag.EdmBf_ShowSelected);
                    bomView.GetRows(out var rows);
                    bomView.GetColumns(out var Columns);

                    foreach (var row in rows)
                    {
                        var rowDate = (IEdmBomCell)row;

                        if (rowDate.GetTreeLevel() == 1)
                        {
                            rowDate.GetVar(Columns[0].mlVariableID, Columns[0].meType, out var PartNumber, out _, out _, out _);
                            rowDate.GetVar(Columns[3].mlVariableID, Columns[3].meType, out var Qty, out _, out _, out _);

                            bom.Add(new BOM { MaterialItem = PartNumber.ToString(), MatReqPC = Qty.ToString() });
                        }
                    }
                }