Export Bill of Materials (BOM) in csv format

This simple plugin exports the Bill Of Materials of your layout. You can customize which properties are included in the output csv.

Install the addon by extracting the zip file to My Commands folder. Then restart the application and the “BOM” button shows up on the Home ribbon tab under Export group.

BOM.zip (1.84 KB)

1 Like

Hi,

I have installed the plugin, thnk you bery much.

I wonder if it is possible to save the columns choice once for all, as for the moment I have to select the value each time.

Regards.

Joachim

Hi,

Could you be so kind and modify the plugin so i generates a xlsx file instead of csv ?

Thank you .

Regards.

Joachim

Hi,
I have started using this in my Visual components, but the Quantity section doesn’t seem to like counting multiple instances as visual components imports them as ‘Comp’, ‘Comp#2’, ‘Comp#3’, etc. any suggestions?
Additionally it’d be nice if it were possible to work out a way of auto sizing the rows to fit.

I have question.
It’s possible to change the code for export Visual Components datas in csv as the Task ID, the Database Path and Database Source ?
Thanks

Jes, you can modify the python script…

Regards
Feature

I want change this python script to save not a csv file but a xlsx file.
I have differents problems with conversion str and int.
Can you see my code and tell me why the problem please.
Thanks

  with open(fileuri, 'w', ) as workbook:
    workbook = xlsxwriter.Workbook(fileuri)
    worksheet = workbook.add_worksheet()
    index = 0
    Convoyeur = getProperty('Paramètre BOM::Présence convoyeur')
    if Convoyeur.Value == 'Oui':
      my_dict = {'[Reference]': [],
                 '[Quantity]': [],
                 '[Task ID]': [],
                 '[Database Path]': [],
                 '[Database Source]': [],
                 'ConveyorLength': [],
                 'ConveyorHeight': [],
                 'ConveyorWidth': [],
                 '[ConveyorType]': []}
      col_num = 0
      includeProp = getProperty('Paramètre BOM::Include')
      if includeProp.Value == 'All':
        components = app.Components
      else:
        components = [x for x in app.Components if x.BOM]
      for c in components:
        index += 1
        value = ''
        for key, value in my_dict.items():

          if col_num == 0:
            if c.VCID == '1d7491e5-225c-47a4-aab5-c04a89badff8':
              worksheet.write(0, col_num, key)
              a += 1
              value = 'Conveyor''%i' % a
              worksheet.write_column(1, col_num, value)
              col_num += 1
            if c.VCID != '1d7491e5-225c-47a4-aab5-c04a89badff8':
              worksheet.write(0, col_num, key)
              a += 1
              value = c.Name
              worksheet.write_column(1, col_num, value)


          if col_num == 1:
            worksheet.write(0, col_num, key)
            value = '1'
            worksheet.write_column(1, col_num, value)


          if col_num == 2:
            worksheet.write(0, col_num, key)
            value = 'A.1'
            worksheet.write_column(1, col_num, value)


          if col_num == 3:
            worksheet.write(0, col_num, key)
            value = '1'
            worksheet.write_column(1, col_num, value)


          if col_num == 4:
            worksheet.write(0, col_num, key)
            value = 'Visual Components.qdb'
            worksheet.write_column(1, col_num, value)


          if col_num == 5 or 6 or 7:
            worksheet.write(0, col_num, key)
            value = c.Material.Name if c.Material else '*NULL*'
            worksheet.write_column(1, col_num, value)



          if col_num == 8:
            worksheet.write(0, col_num, key)
            value = c.getProperty(col_num)
            worksheet.write_column(1, col_num, value)
            if not col_num:
              col_num = c.getProperty('Presets')
            if col_num:
              value = str(col_num)
              worksheet.write_column(1, col_num, value)
          else:
            col_num = c.getProperty(col_num)
            if col_num:
              if type(col_num.Value) == type(some_material):
                value = col_num.Value.Name if col_num.Value else '*NULL*'
                worksheet.write_column(1, col_num, value)
              elif col_num.Type == VC_BOOLEAN:
                value = 'True' if col_num.Value else 'False'
                worksheet.write_column(1, col_num, value)
              elif col_num.Type == VC_REAL:
                value = ('%.3f' % (col_num.Value)).replace('.', ',')
                worksheet.write_column(1, col_num, value)
              elif col_num.Type in [VC_INTEGER, VC_STRING]:
                value = str(col_num.Value)
                worksheet.write_column(1, col_num, value)
              else:
                print('Non supported property "%s" at component "%s"' % (col_num, c.Name))


    workbook.close()

I modify the part with open because the format csv is created here.

Hy,

whats exactly the problem?

Regards
Feature

When I open my file xlsx after run the code with Visual Components the file xlsx opened is white.
Thanks.

Cordialy

Hy,

I would also need to debug this…

Did you see worksheets in your file, may upload one here?

Regards
Feature

I have this error :

The file after was created but it’s empty and when I want to open the file I have the display telling me display and extension is invalid.

Cordialy

Hy,

and what is written in line 184?

Regards
Feature

Hi,

It’s write this :

for key, value in my_dict.items():

Cordially

Hello,

It’s possible to export the datas as BOM with a plugin .NET and not in python ?

Regards
Deros