EBDN - Community - Question & Answers

  Friday, 13 November 2020
  4 Replies
  738 Visits
0
Votes
Undo
Hi everyone,
i'm trying to export a BOM from an electrical drawing made in EB wit VB.NET . I've already coded it years ago in VBA and noticed that 'worksheetcount' has been replaced by 'worksheetgrouping'. I tried using it, but it always return me a worksheet with only one row with added a column 'quantity' that counts all the original worksheet object. This happen also if i set .Grouping.SetGrouping(AttributeId.SupplierPartNumber).
I leave here the function i made if anyone can help me debugging it.


Private Sub esportaListaAcquisti(folderPath As String)

Dim oWorksheet As Worksheet
Dim listKind As New List(Of ObjectKind)
Dim listAttr As New List(Of AttributeId)
Dim cabinetName As String = Application.Selection.FirstOrDefault.Name

listKind.Add(ObjectKind.Device)
listAttr.Add(AttributeId.Material)
listAttr.Add(customAttributeID.MetelSupplierCode)
listAttr.Add(AttributeId.SupplierPartNumber)
listAttr.Add(AttributeId.Description)
listAttr.Add(AttributeId.Manufacturer)

oWorksheet = Application.ActiveProject.EquipmentFolder.ChildByName(cabinetName).ChildByName("Dispositivi").OpenWorksheet(listKind, AttributeId.Material, BinaryOperator.NotEqual, "", WorksheetOpenBehavior.Deep, listAttr)

With oWorksheet
.Grouping.SetGrouping(AttributeId.SupplierPartNumber)
.Sort.Add(AttributeId.Manufacturer, SortDirection.Ascending)
.Refresh()
Dim exportPath As String = folderPath + "\" + cabinetName
Try
If Not File.Exists(exportPath) Then
Directory.CreateDirectory(exportPath)
End If
.Export(WorksheetExportBehavior.CSV, exportPath & "\BOM.csv")
Catch ex As IOException
MsgBox(ex.Message)
End Try
End With
End Sub


I attach also a screenshot for better readability with syntax highlighting