Giter Site home page Giter Site logo

kibom's Introduction

KiBoM

License: MIT PyPI Coverage Status

Configurable BoM generation tool for KiCad EDA (http://kicad.org/)

Description

KiBoM is a configurable BOM (Bill of Materials) generation tool for KiCad EDA. Written in Python, it can be used directly with KiCad software without the need for any external libraries or plugins.

KiBoM intelligently groups components based on multiple factors, and can generate BoM files in multiple output formats.

BoM options are user-configurable in a per-project configuration file.

Installation

KiBoM can be installed via multiple methods:

A. Download

Download the KiBoM package from github and extract the .zip archive to a location on your computer.

B. Git Clone

Use git to clone the source code to your computer:

git clone https://github.com/SchrodingersGat/kibom

C. PIP

KiBom can also be installed through the PIP package manager:

pip install kibom

Note: Take note of which python executable you use when installing kibom - this is the same executable you must use when running the KiBom script from KiCAD (more details below under "Usage")

Installing under PIP is recommended for advanced users only, as the exact location of the installed module must be known to properly run the script from within KiCad.

Usage

The KiBOM_CLI script can be run directly from KiCad or from the command line. For command help, run the script with the -h flag e.g.

python KiBOM_CLI.py -h

usage: KiBOM_CLI.py [-h] [-n NUMBER] [-v] [-r VARIANT] [--cfg CFG]
                    [-s SEPARATOR]
                    netlist output

KiBOM Bill of Materials generator script

positional arguments:
  netlist               xml netlist file. Use "%I" when running from within
                        KiCad
  output                BoM output file name. Use "%O" when running from
                        within KiCad to use the default output name (csv
                        file). For e.g. HTML output, use "%O.html"

optional arguments:
  -h, --help            show this help message and exit
  -n NUMBER, --number NUMBER
                        Number of boards to build (default = 1)
  -v, --verbose         Enable verbose output
  -r VARIANT, --variant VARIANT
                        Board variant(s), used to determine which components are
                        output to the BoM
  -d SUBDIRECTORY, --subdirectory SUBDIRECTORY
                        Subdirectory (relative to output file) within which the
                        BoM(s) should be written.
  --cfg CFG             BoM config file (script will try to use 'bom.ini' if
                        not specified here)
  -s SEPARATOR, --separator SEPARATOR
                        CSV Separator (default ',')
  -k, --no-colon-sep    Don't use : as delimiter in the config file
  --version             show program's version number and exit


netlist The netlist must be provided to the script. When running from KiCad use "%I"

output This is the path to the BoM output. When running from KiCad, usage "%O" for the default option

  • If a suffix is not specified, CSV output format will be used
  • HTML output can be specified within KiCad as: "%O.html" or "%O_BOM.html" (etc)
  • XML output can be specified within KiCad as: "%O.xml" (etc)
  • XSLX output can be specified within KiCad as: "%O.xlsx" (etc)

-n --number Specify number of boards for calculating part quantities

-v --verbose Enable extra debugging information

-r --variant Specify the PCB variant(s). Support for arbitrary PCB variants allows individual components to be marked as 'fitted' or 'not fitted' in a given variant. You can provide muliple variants comma-separated. You can generate multiple BoMs at once for different variants by using semicolon-separation.

-d --subdirectory Specify a subdirectory (from the provided output file) into which the boms should be generated.

--cfg If provided, this is the BoM config file that will be used. If not provided, options will be loaded from "bom.ini"

-s --separator Override the delimiter for CSV or TSV generation

-k --no-colon-sep Only accept = as a delimiter for KEY/VALUE pairs in the config file, enables the use of : in field names


To run from KiCad, simply add the same command line in the Bill of Materials script window. e.g. to generate a HTML output:

alt tag

Quick Start

Download and unzip the files almost anywhere.

When you start the KiCad schematic editor and choose Tools>Generate Bill of Materials expect a Bill of Material dialog. Choose the Add Plugin button, expect a file chooser dialog. Navigate to where you unzipped the files, select the KiBOM_CLI.py file, and choose the Open button. Expect another confirmation dialog and choose OK. Expect the Command Line: text box to be filled in, and for a description of the plugin to appear in the Plugin Info text box. Choose the Generate button. Expect some messages in the Plugin Info text box, and for a .csv file to exist in your KiCad project directory.

If you want other than .csv format, edit the Command Line, for example inserting ".html" after the "%O".

If you want more columns in your BoM, before you generate your BoM, in the schematic editor choose Preferences>Schematic Editor Options and create new rows in the Template Field Names tab. Then edit your components and fill in the fields. KiBoM will reasonably sum rows in the BoM having the same values in your fields. For example, if you have two components both with Vendor=Digikey and SKU=877-5309 (and value and footprints equal), there will be one row with Quantity "2" and References e.g. "R1, R2."

Features

Intelligent Component Grouping

To be useful for ordering components, the BoM output from a KiCad project should be organized into sensible component groups. By default, KiBoM groups components based on the following factors:

  • Part name: (e.g. 'R' for resistors, 'C' for capacitors, or longer part names such as 'MAX232') note: parts such as {'R','r_small'} (which are different symbol representations for the same component) can also be grouped together
  • Value: Components must have the same value to be grouped together
  • Footprint: Components must have the same footprint to be grouped together (this option can be enabled/disabled in the bom.ini configuration file)

Custom Column Grouping

If the user wishes to group components based on additional field values, these can be specified in the preferences (.ini) file

Intelligent Value Matching

Some component values can be expressed in multiple ways (e.g. "0.1uF" === "100n" for a capacitor). KiBoM matches value strings based on their interpreted numerical value, such that components are grouped together even if their values are expressed differently.

Field Extraction

In addition to the default KiCad fields which are assigned to each component, KiBoM extracts and custom fields added to the various components.

Default Fields

The following default fields are extracted and can be added to the output BoM file:

  • Description : Part description as per the schematic symbol
  • References : List of part references included in a particular group
  • Quantity : Number of components included in a particular group
  • Part : Part name as per the schematic symbol
  • Part Lib : Part library for the symbol (default - not output to BoM file)
  • Footprint : Part footprint
  • Footprint Lib : Part footprint library (default - not output to BoM file)
  • Datasheet : Component datasheet extracted either from user-included data, or from part library

User Fields

If any components have custom fields added, these are available to the output BoM file.

Joining Fields

The user may wish to have separate fields in the output BOM file. For example, multiple component parameters such as [Voltage / Current / Tolerance] could be joined into the Value field in the generated BOM file.

Field joining is configured in the bom.ini file. Under the [JOIN] section in the file, multiple join entries can be specified by the user to be joined. Each line is a separate entry, which contains two or more tab-separated field names.

The first name specifies the primary field which be displayed in the output file. The following names specifiy fields which will be joined into the primary field.

Example:

[JOIN]
Value    Voltage  Current  Tolerance

This entry will append the voltage, current and tolerance values into the value field.

Multiple PCB Configurations

KiBoM allows for arbitrary PCB configurations, which means that the user can specify that individual components will be included or excluded from the BoM in certain circumstances.

The preferences (.ini) file provides the fit_field option which designates a particular part field (default = "Config") which the user can specify whether or not a part is to be included.

DNF Parts

To specify a part as DNF (do not fit), the fit_field field can be set to one of the following values: (case insensitive)

  • "dnf"
  • "do not fit"
  • "nofit"
  • "not fitted"
  • "dnp"
  • "do not place"
  • "no stuff"
  • "nostuff"
  • "noload"
  • "do not load"

DNC Parts

Parts can be marked as do not change or fixed by specifying the dnc attribute in the fit_field field.

Note:

If the Value field for the component contains any of these values, the component will also not be included

PCB Variants

To generate a BoM with a custom Variant, the --variant flag can be used at the command line to specify which variant is to be used.

If a variant is specified, the value of the fit_field field is used to determine if a component will be included in the BoM, as follows:

  • If the fit_field value is empty / blank then it will be loaded in ALL variants.
  • If the fit_field begins with a '-' character, if will be excluded from the matching variant.
  • If the fit_field begins with a '+' character, if will ONLY be included in the matching variant.

Multiple variants can be addressed as the fit_field can contain multiple comma-separated values. Multiple BoMs can be generated at once by using semicolon-separated values.

  • If you specify multiple variants
    • If the fit_field contains the variant beginning with a '-' character, it will be excluded irrespective of any other '+' matches.
    • If the fit_field contains the variant beginning with a '+' and matches any of the given variants, it will be included.

e.g. if we have a PCB with three components that have the following values in the fit_field field:

  • C1 -> "-production,+test"
  • C2 -> "+production,+test"
  • R1 -> ""
  • R2 -> "-test"

If the script is run with the flag --variant production then C2, R1 and R2 will be loaded.

If the script is run without the --variant production flag, then R1 and R2 will be loaded.

If the script is run with the flag --variant test, then C1, C2 and R1 will be loaded.

If the script is run with the flags --variant production,test, then C2 and R1 will be loaded.

If the script is run with the flags --variant production;test;production,test, then three separate BoMs will be generated one as though it had been run with --variant production, one for --variant test, and one for --variant production,test.

Regular Expression Matching

KiBoM features two types of regex matching : "Include" and "Exclude" (each of these are specified within the preferences (bom.ini) file).

If the user wishes to include ONLY parts that match one-of-many regular expressions, these can be specified in REGEX_INCLUDE section of the bom.ini file

If the user wishes to exclude components based on one-of-many regular expressions, these are specified in the REGEX_EXCLUDE section of the bom.ini file

(Refer to the default bom.ini file for examples)

Multiple File Outputs

Multiple BoM output formats are supported:

  • CSV (Comma separated values)
  • TSV (Tab separated values)
  • TXT (Text file output with tab separated values)
  • XML
  • HTML
  • XLSX (Needs XlsxWriter Python module)

Output file format selection is set by the output filename. e.g. "bom.html" will be written to a HTML file, "bom.csv" will be written to a CSV file.

Digi-Key Linking

If you have a field containing the Digi-Key part number you can make its column to contain links to the Digi-Key web page for this component. (Note: Digi-Key links will only be generated for the HTML output format).

Instructions

Specify a column (field) to use as the digikey_link field in the configuration file (ie. bom.ini). The value for this option is the column you want to convert into a link to the Digi-Key. Note that this field must contian a valid Digi-Key part number in each row.

For example:

digikey_link = digikeypn

This will render entries in the column digikeypn as hyperlinks to the component webpage on the Digi-Key website.

Limitations

Note that Digi-Key URL rendering will only be rendered for HTML file outputs.

Configuration File

BoM generation options can be configured (on a per-project basis) by editing the bom.ini file in the PCB project directory. This file is generated the first time that the KiBoM script is run, and allows configuration of the following options.

  • ignore_dnf : Component groups designated as 'DNF' (do not fit) will be excluded from the BoM output
  • use_alt : If this option is set, grouped references will be printed in the alternate compressed style eg: R1-R7,R18
  • number_rows : Add row numbers to the BoM output
  • group_connectors : If this option is set, connector comparison based on the 'Value' field is ignored. This allows multiple connectors which are named for their function (e.g. "Power", "ICP" etc) can be grouped together.
  • test_regex : If this option is set, each component group row is test against a list of (user configurable) regular expressions. If any matches are found, that row is excluded from the output BoM file.
  • merge_blank_field : If this option is set, blank fields are able to be merged with non-blank fields (and do not count as a 'conflict')
  • ref_separator : This is the character used to separate reference designators in the output, when grouped. Defaults to " ".
  • fit_field : This is the name of the part field used to determine if the component is fitted, or not.
  • complex_variant : This enable a more complex processing of variant fields using the VARIANT:FIELD format for the name of symbol properties
  • output_file_name : A string that allows arbitrary specification of the output file name with field replacements. Fields available:
    • %O : The base output file name (pulled from kicad, or specified on command line when calling script).
    • %v : version number.
    • %V : variant name, note that this will be ammended according to variant_file_name_format.
  • variant_file_name_format : A string that defines the variant file format. This is a unique field as the variant is not always used/specified.
  • make_backup : If this option is set, a backup of the bom created before generating the new one. The option is a string that allows arbitrary specification of the filename. See output_file_name for available fields.
  • number_boards : Specifies the number of boards to produce, if none is specified on CLI with -n.
  • board_variant : Specifies the name of the PCB variant, if none is specified on CLI with -r.
  • hide_headers : If this option is set, the table/column headers and legends are suppressed in the output file.
  • hide_pcb_info : If this option is set, PCB information (version, component count, etc) are suppressed in the output file.
  • IGNORE_COLUMNS : A list of columns can be marked as 'ignore', and will not be output to the BoM file. By default, the Part_Lib and Footprint_Lib columns are ignored.
  • GROUP_FIELDS : A list of component fields used to group components together.
  • COMPONENT_ALIASES : A list of space-separated values which allows multiple schematic symbol visualisations to be consolidated.
  • REGEX_INCLUDE : A list of regular expressions used to explicitly include components. If there are no regex here, all components pass this test. If there are regex here, then a component must match at least one of them to be included in the BoM.
  • REGEX_EXCLUDE : If a component matches any of these regular expressions, it will not be included in the BoM. Important: the REGEX_INCLUDE section has more precedence.

Example configuration file (.ini format) default values shown

[BOM_OPTIONS]
; General BoM options here
; If 'ignore_dnf' option is set to 1, rows that are not to be fitted on the PCB will not be written to the BoM file
ignore_dnf = 1
; If 'use_alt' option is set to 1, grouped references will be printed in the alternate compressed style eg: R1-R7,R18
use_alt = 0
; If 'number_rows' option is set to 1, each row in the BoM will be prepended with an incrementing row number
number_rows = 1
; If 'group_connectors' option is set to 1, connectors with the same footprints will be grouped together, independent of the name of the connector
group_connectors = 1
; If 'test_regex' option is set to 1, each component group will be tested against a number of regular-expressions (specified, per column, below). If any matches are found, the row is ignored in the output file
test_regex = 1
; If 'merge_blank_fields' option is set to 1, component groups with blank fields will be merged into the most compatible group, where possible
merge_blank_fields = 1
; Specify output file name format, %O is the defined output name, %v is the version, %V is the variant name which will be ammended according to 'variant_file_name_format'.
output_file_name = %O_bom_%v%V
; Specify the variant file name format, this is a unique field as the variant is not always used/specified. When it is unused you will want to strip all of this.
variant_file_name_format = _(%V)
; Field name used to determine if a particular part is to be fitted
fit_field = Config
; Make a backup of the bom before generating the new one, using the following template
make_backup = %O.tmp
; Default number of boards to produce if none given on CLI with -n
number_boards = 1
; Default PCB variant if none given on CLI with -r
board_variant = "default"
; Complex variant field processing (disabled by default)
complex_variant = 0
; When set to 1, suppresses table/column headers and legends in the output file.
; May be useful for testing purposes.
hide_headers = 0
; When set to 1, PCB information (version, component count, etc) is not shown in the output file.
; Useful for saving space in the HTML output and for ensuring CSV output is machine-parseable.
hide_pcb_info = 0

[IGNORE_COLUMNS]
; Any column heading that appears here will be excluded from the Generated BoM
; Titles are case-insensitive
Part Lib
Footprint Lib

[COLUMN_ORDER]
; Columns will apear in the order they are listed here
; Titles are case-insensitive
Description
Part
Part Lib
References
Value
Footprint
Footprint Lib
Quantity Per PCB
Build Quantity
Datasheet

[GROUP_FIELDS]
; List of fields used for sorting individual components into groups
; Components which match (comparing *all* fields) will be grouped together
; Field names are case-insensitive
Part
Part Lib
Value
Footprint
Footprint Lib

[COMPONENT_ALIASES]
; A series of values which are considered to be equivalent for the part name
; Each line represents a tab-separated list of equivalent component name values
; e.g. 'c c_small cap' will ensure the equivalent capacitor symbols can be grouped together
; Aliases are case-insensitive
c	c_small	cap	capacitor
r	r_small	res	resistor
sw	switch
l	l_small	inductor
zener	zenersmall
d	diode	d_small

[REGEX_INCLUDE]
; A series of regular expressions used to include parts in the BoM
; If there are any regex defined here, only components that match against ANY of them will be included in the BOM
; Column names are case-insensitive
; Format is: "ColumName	Regex" (tab-separated)

[REGEX_EXCLUDE]
; A series of regular expressions used to exclude parts from the BoM
; If a component matches ANY of these, it will be excluded from the BoM
; Column names are case-insensitive
; Format is: "ColumName	Regex" (tab-separated)
References	^TP[0-9]*
References	^FID
Part	mount.*hole
Part	solder.*bridge
Part	test.*point
Footprint	test.*point
Footprint	mount.*hole
Footprint	fiducial

Example

A simple schematic is shown below. Here a number of resistors, capacitors, and one IC have been added to demonstrate the BoM output capability. Some of the components have custom fields added ('Vendor', 'Rating', 'Notes')

alt tag

Here, a number of logical groups can be seen:

R1 R2 Resistors R1 and R2 have the same value (470 Ohm) even though the value is expressed differently. Resistors R1 and R2 have the same footprint

R3 R4 Resistors R3 and R4 have the same value and the same footprint

R5 While R5 has the same value as R3 and R4, it is in a different footprint and thus cannot be placed in the same group.

C1 C2 C1 and C2 have the same value and footprint

C3 C5 C3 and C5 have the same value and footprint

C4 C4 has a different footprint to C3 and C5, and thus is grouped separately

HTML Output

The output HTML file is generated as follows:

alt tag

alt tag

Here the components are correctly grouped, with links to datasheets where appropriate, and fields color-coded.

CSV Output

A CSV file output can be generated simply by changing the file extension

Component,Description,Part,References,Value,Footprint,Quantity,Datasheet,Rating,Vendor,Notes
1,Unpolarized capacitor,C,C1 C2,0.1uF,C_0805,2,,,,
2,Unpolarized capacitor,C,C3 C5,2.2uF,C_0805,2,,,,
3,Unpolarized capacitor,C,C4,2.2uF,C_0603,1,,100V X7R,,
4,"Connector, single row, 01x09",CONN_01X09,P2,Comms,JST_XH_S09B-XH-A_09x2.50mm_Angled,1,,,,
5,"Connector, single row, 01x09",CONN_01X09,P1,Power,JST_XH_S09B-XH-A_09x2.50mm_Angled,1,,,,
6,Resistor,R,R3 R4,100,R_0805,2,,,,
7,Resistor,R,R5,100,R_0603,1,,0.5W 0.5%,,
8,Resistor,R,R1 R2,470R,R_0805,2,,,Digikey,
9,"Dual RS232 driver/receiver, 5V supply, 120kb/s, 0C-70C",MAX232,U1,MAX232,DIP-16_W7.62mm,1 (DNF),http://www.ti.com/lit/ds/symlink/max232.pdf,,,Do not fit

Component Count:,13
Component Groups:,9
Schematic Version:,A.1
Schematic Date:,2016-05-15
BoM Date:,15-May-16 5:27:07 PM
Schematic Source:,C:/bom_test/Bom_Test.sch
KiCad Version:,"Eeschema (2016-05-06 BZR 6776, Git 63decd7)-product"

XML Output

An XML file output can be generated simply by changing the file extension

<?xml version="1.0" ?>
<KiCad_BOM BOM_Date="14-Jan-18 5:27:03 PM" KiCad_Version="Eeschema (2016-05-06 BZR 6776, Git 63decd7)-product" Schematic_Date="2016-05-15" Schematic_Source="C:/bom_test/Bom_Test.sch" Schematic_Version="A.1" components="13" groups="9">
    <group Datasheet="" Description="Unpolarized capacitor" Footprint="C_0805" Notes="" Part="C" Quantity="2" Rating="" References="C1 C2" Value="0.1uF" Vendor=""/>
    <group Datasheet="" Description="Unpolarized capacitor" Footprint="C_0805" Notes="" Part="C" Quantity="2" Rating="" References="C3 C5" Value="2.2uF" Vendor=""/>
    <group Datasheet="" Description="Unpolarized capacitor" Footprint="C_0603" Notes="" Part="C" Quantity="1" Rating="100V X7R" References="C4" Value="2.2uF" Vendor=""/>
    <group Datasheet="" Description="Connector, single row, 01x09" Footprint="JST_XH_S09B-XH-A_09x2.50mm_Angled" Notes="" Part="CONN_01X09" Quantity="1" Rating="" References="P2" Value="Comms" Vendor=""/>
    <group Datasheet="" Description="Connector, single row, 01x09" Footprint="JST_XH_S09B-XH-A_09x2.50mm_Angled" Notes="" Part="CONN_01X09" Quantity="1" Rating="" References="P1" Value="Power" Vendor=""/>
    <group Datasheet="" Description="Resistor" Footprint="R_0805" Notes="" Part="R" Quantity="2" Rating="" References="R3 R4" Value="100" Vendor=""/>
    <group Datasheet="" Description="Resistor" Footprint="R_0603" Notes="" Part="R" Quantity="1" Rating="0.5W 0.5%" References="R5" Value="100" Vendor=""/>
    <group Datasheet="" Description="Resistor" Footprint="R_0805" Notes="" Part="R" Quantity="2" Rating="" References="R1 R2" Value="470R" Vendor="Digikey"/>
    <group Datasheet="http://www.ti.com/lit/ds/symlink/max232.pdf" Description="Dual RS232 driver/receiver, 5V supply, 120kb/s, 0C-70C" Footprint="DIP-16_W7.62mm" Notes="Do not fit" Part="MAX232" Quantity="1 (DNF)" Rating="" References="U1" Value="MAX232" Vendor=""/>
</KiCad_BOM>

XLSX Output

An XLSX file output can be generated simply by changing the file extension

Contributors

With thanks to the following contributors:

kibom's People

Contributors

angusp avatar apcountryman avatar bombledmonk avatar bootchk avatar diegoherranz avatar eeintech avatar evidlo avatar fauxpark avatar frankalicious avatar gbmhunter avatar haata avatar hkennyv avatar kcalden avatar kerrsmith avatar kylemanna avatar leoheck avatar marcelobarrosalmeida avatar mrsurly avatar n0dyjeff avatar pointhi avatar schneidersoft avatar schrodingersgat avatar set-soft avatar suuppl avatar suzizecat avatar swij avatar szabodabo avatar trentks avatar ximi1970 avatar zwlp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kibom's Issues

Consider adding license

Stumbled on your repo and am excited with what I've found so far, but have one request:

Can you add a license so I can understand how I can use it?

I might suggest MIT license if you want to be openly permissive, quick overview at tl;dr legal

Thanks!

Values starting with + are interpreted as variant (e.g. +5V)?

I want to export a BOM, where an internal part number is a primary key (unique) in the exported list.

But test points, which all have the same part number (NAP), are grouped into 2 different rows:

Part        | Part Lib    | References                      | Value       | Footprint                | Footprint Lib | Quantity Per PCB | InternalName
Montageloch | t14_mech    | MH301 P1601 S301 TP305-TP306... | Montageloch | MH_DK_M3_4mm-DSD-special | t14_mech      | 16               | NAP
Testpunkt   | t14_mech    | TP301-TP304 TP307-TP308         | +5V         | LSP13                    | dsd-cc-eagle  | 6 (DNF)          | NAP

Can this "feature" be turned off?

Unicode Encode Error in parsing date

In some languages date field can contain unicode characters and it crushes while parsing date.
To fix that I've did:

def getDate(self):
    """Return the date + time string generated by the tree creation tool"""
    return self.design.get("date").encode('ascii', 'ignore')

Force part insertion in BOM

Hi there!

I have several parts that I want to include in my BOM but those parts contains words in their footprints or in their library names that makes them excluded.
Example:
Test points:
my_library:TP_SMD_5019
Connectors:
my_library:DSUB-9_Female_Horizontal_P2.74x2.54mm_EdgePinOffset10.07mm_Housed_MountingHolesOffset11mm
Connector_Phoenix_MC:PhoenixContact_MC_1,5_3-GF-3.5_1x03_P3.50mm_Horizontal_ThreadedFlange_MountHole

Anyting that contains the words "test point" or "mount hole" is excluded and it seems that there is no option to bypass that.

In my case, I use a field caled "Part Number" with the device part number.
Is there any chance to force any device that contains a value in the field "Part Number" to be included in the BOM?

Best regards,
Cristiano Rodrigues

Grouping different values into one line

Hi,

i'm trying to group different values into one group (aka one line).
Our primary grouping indicator is a field called "InternalName", which must be unique in the exported BOM.

This works, but when the only difference are the values, e.g. 10k/30mW and 10/50mW, only one of them appears in the 'Value' column. Is it possible, that they are all listed?

As a reference, here is our ini-file:
bom2.ini.zip

kind regards, Karl

fit_field and output subdirectory problem

I'm using PIP version 1.7.0 on linux. I found two issues:

  1. I specified fit_field = VariantPCB. When I generate BOM files and this parameter is:
  • compleatly empty - Quantity = 1 - that's ok
  • any character inside, it could be anything: "" or - or a - Quantity = 1(DNC)
  • DNF - Quantity = 1(DNF)(DNC)
  • parameters of PCB variants doesn't work too. "-VAR1" or "+VAR2" gives Quantity = 1(DNC)
  1. In PIP version doesn't work putting output files to specified folder (command line -d BOM). Files are generated correctly (in my test project: temp_BOM_rev.85_2.html), there is generated new folder, with name temp.html, which is empty. There's no folder "BOM".
    In previous version, clon from github it was working fine.

One more thing about linux version of KiCad. There is no possibility to add only the command line in BOM script. Program needs to get file, and then gives access to edit and run " python3 -m kibom "%I" "%O" ".
I override this by creating a new .py file:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
@package

KiBOM - Bill of Materials generation for KiCad

Command line:
	python3 -m kibom "%I" "%O.csv" -s ; -d BOM -n 1 -r default

	"%O" - output format
		- "%O.csv"
		- "%O.html"

	-s - column separator
	-d - output subdirectory
	-n - number of PCB to calculate
	-r - variant of PCB 
"""
print("\n\nTO GENERATE OUTPUT FILES USE COMMAND LINE FROM DESCRIPTION")

My test command line:
python3 -m kibom "%I" "%O.html" -s ; -d BOM -n 1

Regards

Ubuntu installation with pip file KiBOM_CLI.py not installed

pip show KiBOM

Name: kibom
Version: 1.7.1
Summary: Bill of Materials generation tool for KiCad EDA
Home-page: https://github.com/SchrodingersGat/KiBom
Author: Oliver Walters
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python3.7/dist-packages
Requires: xlsxwriter
Required-by:

ls /usr/local/lib/python3.7/dist-packages/kibom

bom_writer.py csv_writer.py init.py preferences.py units.py xml_writer.py
columns.py debug.py main.py pycache version.py
component.py html_writer.py netlist_reader.py sort.py xlsx_writer.py

kiBOM_CLI.py is missing
Manually downloading the tar.gz shows also that this file is missing

bom.ini file does not support "True"

The generated "ini" file contains the two lines: hide_headers = False and hide_pcb_info = False, however, setting the values to "True" does not work. I.e hide_pcb_info = True does not work.

New field defined from database query

Hi,
I'm trying to add KiBoM a new feature: define new fields whose values will be database queries.
Right now, I added a [DATABASE] section to the config file, and a database.py new file to handle all the related function.
I am able to connect and disconect to the database, and now, I'm trying to define a new field for a component, but I can't understand how to do this...

In KiBoM_CLI.py, I understand that this new code should go after:

# Read out the netlist
net = netlist(input_file, prefs=pref)

# Extract the components
components = net.getInterestingComponents()

I would like to insert a new field with its value for each component. How could I do it?

Thanks,

Explicitly output fields as text

Importing csv/tsv files in libreoffice correctly requires that you set the type of each column manually.
Otherwise texts like the footprint "0805" will be imported as a number and turned into 805.

It would be helpful to have Kibom wrap fields in quotes to allow import into libreoffice with the "import quoted fields as text" feature.

Naturaly those field that do contain numeric data like the Qty and Build Quantity should not get quotes.

Error with KiCAD 5.1.2 [Linux\

I've received the error below with KiBOM on several installations. If I go in and comment out line 207 in the related module and then add missing items to the .ini file that is generated, I can ultimately get KiBOM to work.
This error below resulted from running KiBOM within KiCAD with the following command line specified:

python "/home/brian/Documents/KiCAD/KiBoM-master/KiBOM_CLI.py" "%I" "%O.html"

Has anyone else had this problem?

Could this be related to "Minor Fix #29"?

Thanks, Brian

Result is below:
------ include -------
Run command:
python "/home/brian/Documents/KiCAD/KiBoM-master/KiBOM_CLI.py" "/home/brian/Documents/KiCAD/Micro_Regulator_1/MicroRegulator1/MicroRegulator1.xml" "/home/brian/Documents/KiCAD/Micro_Regulator_1/MicroRegulator1/MicroRegulator1.html"

Command error. Return code 1
Info messages:
PCB variant: default

Error messages:
Traceback (most recent call last):
File "/home/brian/Documents/KiCAD/KiBoM-master/KiBOM_CLI.py", line 202, in
result = writeVariant(variant, args)
File "/home/brian/Documents/KiCAD/KiBoM-master/KiBOM_CLI.py", line 76, in writeVariant
pref.Write(config_file)
File "/home/brian/Documents/KiCAD/KiBoM-master/bomlib/preferences.py", line 207, in Write
self.addOption(cf, self.OPT_INCLUDE_VERSION, self.includeVersionNumber, comment="If '{opt}' option is set to 1, the schematic version number will be appended to the filename.")
AttributeError: BomPref instance has no attribute 'OPT_INCLUDE_VERSION'

Workaround for broken Nightly - ConfigParser.NoOptionError

At some point in the Nightly builds of KiCAD, something changed that seems to have broken KiBoM. I was getting ConfigParser.NoOptionErrors in two places.

I was able to work around the issue (in an inelegant way) by changing lines 143-144 preferences.py in bomlib to:

        self.outputFileName = "bom"
        self.variantFileNameFormat = "csv"

TypeError: get() got an unexpected keyword argument 'fallback'

I am using the latest version of KiBoM (master branch as of today) with KiCAD v5.1.6 on Ubuntu 18.04.

I am invoking KiBoM using the KiCAD GUI. The first time (when no bom.ini is present) it works fine. However when I click Generate a second time it fails with the following error (I have made no bom.ini modifications):

Error messages:
Traceback (most recent call last):
  File "/home/ghunter/repos/kibom/KiBOM_CLI.py", line 28, in <module>
    main()
  File "/home/ghunter/repos/kibom/kibom/__main__.py", line 175, in main
    pref.Read(config_file)
  File "/home/ghunter/repos/kibom/kibom/preferences.py", line 147, in Read
    fallback=self.outputFileName)
TypeError: get() got an unexpected keyword argument 'fallback'

Fields case generate issues

I have a Field named Mouser and other MOUSER
It only outputs the Mouser fields and the other does not appear.

`UnicodeEncodeError: ‘ascii’ codec can’t encode character` when reporting Field Conflicts

As discussed, for example, here, KiBoM can sometimes fail with UnicodeEncodeError: ‘ascii’ codec can’t encode character if Unicode characters exist in the schematic's component fields.

The issue can be manually worked around by replacing common Unicode characters in schematics like "µ" (\xb5) with "u". But Unicode characters seem to creep into even the plainest of schematics these days, with auto populated fields from manufacturers like "Würth Electronics" (\xfc), and DigiKey descriptions like "±20ppm" (\xb1). So I still see this error a lot.

In this issue, the offending line of code is:

File “/path/to/KiBoM/bomlib/component.py”, line 515, in updateField
    fld=fieldData))

which is only executed if there are Field Conflicts.

alt_wrap = 1 strange results, or at least missing documentation.

I don't get the idea of this option.
It introduces \n characters in the "References" column, this isn't a good idea for most formats:

  • HTML/XML: white spaces are equivalent, no difference between ' ' and '\n'
  • CSV: the \n isn't escaped and the row is cut. OpenOffice supports it, but I wonder if simpler programs can interpret it. Any program reading line by line will break.
  • XLSX: in this case you have better options, like make the cell adjust to text.

In any case the documentation should state which formats are supposed to suport it and the fact that it only works with "use_alt = 1"

KiCad dialog defaults output filename without suffix

When I first tried it on Ubuntu, KiCad 4.0.2, the KiCad BOM dialog generated a command line for me without a suffix on the output file name i.e. "%O". Then when you choose Generate button, it says it succeeded (the app returns 0, it should return -1) but there was no file generated and there was a message that the extension was not supported.

I think that the code should append a suffix if any passed suffix is not supported. My reasoning is that for nieve users who don't know to change the command line, the program should do something reasonable.

I have forked and fixed and will submit a pull request. Of course you can reject it.

BTW, thanks very much, I appreciate the lack of dependency on other Python packages and the feature set is just what I need for my use case: generating a BOM to submit to a vendor, grouped appropriately.

No grouping side effect

I'm not sure about the following behavior:

KiBoM/kibom/component.py

Lines 120 to 121 in 06a1486

if len(self.prefs.groups) == 0:
return False

This disables the grouping mechanism, this is OK. But the side effect is that multi-part components will be repeated (as many times as sub-parts). I this the code should be:

if len(self.prefs.groups) == 0: 
    return self.getRef() == other.getRef()

So we don't get the same ref multiple times.

quoted commas in csv

When submitting csv to Digikey, in the Description (or Value?) column I had text having a comma. In the csv, the whole text was quoted. Digikey seems to recognize the quoted comma as a column separator. I don't know enough about the csv specification to know where the issue belongs, but probably with Digikey, and you should dismiss this issue as a hint to users not to use commas in their fields.

Thanks again.

exception on variant matching

I'm getting an exception when running KiBoM, using the +<VARIANT> and -<VARIANT> syntax
in the config field:

KiBOM version 1.7.1
 Output directory: '/home/michael/kicad/Marble-Mini'
 Input: /home/michael/kicad/Marble-Mini/AMC_FMC_Carrier-PcbDoc.xml
 Configuration file: /home/michael/kicad/Marble-Mini/bom.ini
 PCB variant: standalone
Traceback (most recent call last):
  File "/usr/lib/python3.8/pdb.py", line 1701, in main
    pdb._runmodule(mainpyfile)
  File "/usr/lib/python3.8/pdb.py", line 1546, in _runmodule
    self.run(code)
  File "/usr/lib/python3.8/bdb.py", line 580, in run
    exec(cmd, globals, locals)
  File "/home/michael/kicad/KiBoM/kibom/__main__.py", line 3, in <module>
    """
  File "/home/michael/kicad/KiBoM/kibom/__main__.py", line 189, in main
    result = writeVariant(input_file, output_dir, output_file, variant, pref)
  File "/home/michael/kicad/KiBoM/kibom/__main__.py", line 54, in writeVariant
    groups = net.groupComponents(components)
  File "/home/michael/kicad/KiBoM/kibom/netlist_reader.py", line 344, in groupComponents
    if g.matchComponent(c):
  File "/home/michael/kicad/KiBoM/kibom/component.py", line 503, in matchComponent
    if c == self.components[0]:
  File "/home/michael/kicad/KiBoM/kibom/component.py", line 117, in __eq__
    if self.isFixed() != other.isFixed():
  File "/home/michael/kicad/KiBoM/kibom/component.py", line 354, in isFixed
    if opt[1:].lower() == self.prefs.pcbConfig.lower():
AttributeError: 'list' object has no attribute 'lower'
Uncaught exception. Entering post mortem debugging

this patch fixes it

diff --git a/kibom/component.py b/kibom/component.py
index 2eef873..0943855 100644
--- a/kibom/component.py
+++ b/kibom/component.py
@@ -346,12 +346,12 @@ class Component():
 
         for opt in opts:
             # Options that start with '-' are explicitly removed from certain configurations
-            if opt.startswith('-') and opt[1:].lower() == self.prefs.pcbConfig.lower():
+            if opt.startswith('-') and opt[1:].lower() in self.prefs.pcbConfig:
                 result = False
                 break
             if opt.startswith("+"):
                 result = False
-                if opt[1:].lower() == self.prefs.pcbConfig.lower():
+                if opt[1:].lower() in self.prefs.pcbConfig:
                     result = True
 
         # by default, part is not fixed

Installing Kibom in windows

the readme for installing kibom in windows is unclear

the readme still mentions KiBOM_CLI.py in the quick start section

trying to use the 2.7 python from kicad appears not to work
C:\Program Files\KiCad\bin>pip install kibom
works
however
python -m kibom "%I" "%O"
in the BOM window gets
Error messages: Traceback (most recent call last): File "C:\Program Files\KiCad\lib\python2.7/runpy.py", line 174, in _run_module_as_main "__main__", fname, loader, pkg_name) File "C:\Program Files\KiCad\lib\python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "C:\Program Files\KiCad\lib\python2.7\site-packages\kibom/__main__.py", line 198, in <module> main() File "C:\Program Files\KiCad\lib\python2.7\site-packages\kibom/__main__.py", line 170, in main pref.Read(config_file) File "C:\Program Files\KiCad\lib\python2.7\site-packages/kibom/preferences.py", line 143, in Read self.outputFileName = cf.get(self.SECTION_GENERAL, self.OPT_OUTPUT_FILE_NAME) File "C:\Program Files\KiCad\lib\python2.7/ConfigParser.py", line 340, in get raise NoOptionError(option, section) ConfigParser.NoOptionError: No option u'output_file_name' in section: u'BOM_OPTIONS'

trying with a separate install of python3 gets (with paths removed)

Requirement already satisfied: kibom in c:\users\fireblade\appdata\local\programs\python\python38-32\lib\site-packages (1.7.1)
Requirement already satisfied: xlsxwriter in c:\users\fireblade\appdata\local\programs\python\python38-32\lib\site-packages (from kibom) (1.2.9)

C:\Users\fireblade>python -m kibom "<inpath>" "<outpath>"
 KiBOM version 1.7.1
 Output directory: '<outpath>'
 Input: <inpath>
Traceback (most recent call last):
  File "C:\Users\fireblade\AppData\Local\Programs\Python\Python38-32\lib\configparser.py", line 789, in get
    value = d[option]
  File "C:\Users\fireblade\AppData\Local\Programs\Python\Python38-32\lib\collections\__init__.py", line 898, in __getitem__
    return self.__missing__(key)            # support subclasses that define __missing__
  File "C:\Users\fireblade\AppData\Local\Programs\Python\Python38-32\lib\collections\__init__.py", line 890, in __missing__
    raise KeyError(key)
KeyError: 'output_file_name'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\fireblade\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\fireblade\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\fireblade\AppData\Local\Programs\Python\Python38-32\lib\site-packages\kibom\__main__.py", line 198, in <module>
    main()
  File "C:\Users\fireblade\AppData\Local\Programs\Python\Python38-32\lib\site-packages\kibom\__main__.py", line 170, in main
    pref.Read(config_file)
  File "C:\Users\fireblade\AppData\Local\Programs\Python\Python38-32\lib\site-packages\kibom\preferences.py", line 143, in Read
    self.outputFileName = cf.get(self.SECTION_GENERAL, self.OPT_OUTPUT_FILE_NAME)
  File "C:\Users\fireblade\AppData\Local\Programs\Python\Python38-32\lib\configparser.py", line 792, in get
    raise NoOptionError(option, section)
configparser.NoOptionError: No option 'output_file_name' in section: 'BOM_OPTIONS'```

Revision/configuration vs variant

Hi,

First of all, thanks for this tool. I haven't used it yet, but looks perfect for my needs.

While reading the documentation, I've seen the --revision parameter and I find it misleading. Revision to me, means version, as in v3, v4.1, rev2 or something like that. Also configuration is used in some places for this, which is a bit better but I think the industry standard for this is variant which in fact is the word you use in the help to explain it.

If you wanted to use the word variant instead, I can provide a PR. At least for the docs, don't know if you would want to change the API too (or anything at all).

Thanks!

Provide a packaging method

It would be nice if this program could be packaged so that users could install it just by using easy_install, pip or other packaging tools.

Merge blank fields logic

The current logic is:

KiBoM/kibom/component.py

Lines 98 to 100 in 06a1486

if this_field == "" or other_field == "":
if not self.prefs.mergeBlankFields:
return False

I don't get it. If the idea is to loosly group fields: should't we be doing a return True?
I mean:

 if this_field == "" or other_field == "": 
     if self.prefs.mergeBlankFields: 
         return True

Note that even when the condition seems to be equivalent it isn't.
In this version of the code we have a chance to return True, in the other don't.

Strings wrapped in b'' in .csv output

Just updated to the most recent version. Unfortunately, it creates a .csv output as follows with the strings wrapped in b'...':

Component,Description,Part,References,Value,Footprint,Quantity Per PCB,Datasheet,Manufacturer,PartNumber,Remarks,Alternative,Config,DNP,Supplier
1,b'Unpolarized capacitor',b'C',b'C9 C10 C16 C19 C24 C25 C26 C30 C31 C32 C34 C39 C42',b'100n',b'C_0603_1608',b'13',b'',b'Yageo',b'CC0603KRX7R9BB104',b'',b'',b'',b'',b''

Using Python 3.7.0 on Linux.

fit_field not working on Win7

I have a bom.ni local file where:

; Field name used to determine if a particular part is to be fitted
fit_field = FIT

then to test KiBoM I edited a capacitor (C4) on the schematic adding the FIT field filled with:
"+a,-b"

this is my command as typed in Kicad:
python "C:\Dati\Kicad\scripts\KiBoM-master/KiBOM_CLI.py" "-r b" "%I" "%O.html"

on the html file I would expect to don't see C4 listed, instead it is listed and the field on the FIT column contains "+a,-b"

this is my command as typed in Kicad:
python "C:\Dati\Kicad\scripts\KiBoM-master/KiBOM_CLI.py" "-r a" "%I" "%O.html"

on the html file I would expect to see C4 listed, it is listed and the field on the FIT column contains "+a,-b"

In general terms I would expect a different behaviour:
if -r present on the command row: in FIT only fields containing - and + will be considered and the output will be produced with or without them only reporting texts not containing - and + (for instance dnf), if all the fileds will be empty or no dnf (And similar) texts are not found the column will not br printed
if -r not present on the command row: only reporting texts not containing - and + (for instance dnf) if all the fileds will be empty or no dnf (And similar) texts are not found the column will not br printed

Plugin fails Kicad 5.1.7

I upgraded my KiCAD to version 5.1.7 today and I noticed that KiBOM_CLI crashes:

Run command:
python “/Users/stevenslupsky/kicad/KiBoM/KiBOM_CLI.py” “-dbom” “/Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Kicad/PB_16/Receiver_Out/Receiver_Out.xml” “/Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Kicad/PB_16/Receiver_Out/Receiver_Out.xls”

Command error. Return code 1
Info messages:
 KiBOM version 1.8.0
 Output directory: ‘/Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Kicad/PB_16/Receiver_Out/bom’
 Input: /Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Kicad/PB_16/Receiver_Out/Receiver_Out.xml
 Configuration file: /Users/stevenslupsky/Library/Mobile Documents/com~apple~CloudDocs/Kicad/PB_16/Receiver_Out/bom.ini
 PCB variant: [u’default’]

Error messages:
Traceback (most recent call last):
  File “/Users/stevenslupsky/kicad/KiBoM/KiBOM_CLI.py”, line 28, in <module>
    main()
  File “/Users/stevenslupsky/kicad/KiBoM/kibom/__main__.py”, line 194, in main
    result = writeVariant(input_file, output_dir, output_file, variant, pref)
  File “/Users/stevenslupsky/kicad/KiBoM/kibom/__main__.py”, line 55, in writeVariant
    groups = net.groupComponents(components)
  File “/Users/stevenslupsky/kicad/KiBoM/kibom/netlist_reader.py”, line 357, in groupComponents
    g.updateFields(self.prefs.useAlt)
  File “/Users/stevenslupsky/kicad/KiBoM/kibom/component.py”, line 614, in updateFields
    self.fields[ColumnList.COL_DESCRIPTION] = self.components[0].getDescription()
  File “/Users/stevenslupsky/kicad/KiBoM/kibom/component.py”, line 199, in getDescription
    raise AttributeError(‘Could not get description for part {}{}.’.format(self.getPrefix()),
IndexError: tuple index out of range

I tried it for csv, html or xls output and observed the same result.

I am not sure if the upgrade did this or something else is broken.

Any string in "not_fitted" marks components as DNF

Any string entered in the "not_fitted" field is marked as (DNF)

Script string:
python "C:\Program Files\KiCad\bin\plugins\KiBoM-master\KiBOM_CLI.py" "%I" "%O_BOM.html"

bom.ini:

ignore_dnf = 0
fit_field = Fitted
board_variant = default

Output generated:

Nr. References Value Quantity Per PCB Fitted
63 U5 24LC256 1 (DNF) +CFG1
64 U14 AMS1117-3.3 1 (DNF) -CFG1
65 U11 CRE1S0505SC 1 (DNF) DNF
66 U18 FT230XS 1 (DNF) RandomText

KiCAD: (5.1.2)-1, release build, on Windows 10 64-bit

Update:
I get the same results in Ubuntu 19.04 with Kicad 5.1.2-f72e74a84ubuntu19.04.1, release build

Set column order

It would be great to be able to specify the specific order of the columns from the bom.ini file.

Currently they tend to end up in an unsuitable order, and have to be manually rearranged every time the BOM is generated.

Group References into ranges

For boards where there are many identical components, it would be good to have the option to group references together like KiField does.

For example instead of:

R1, R4, R5, R6, R7, R8, R9, R10

you could have:

R1, R4-R10

Ohm symbol not detected as unit

The ohm detection is wrong:

UNIT_R = ["r", "ohms", "ohm", u"Ω"]

We always apply lower() so we never really get uppercase omega.
This is the correct list:

UNIT_R = ["r", "ohms", "ohm", u'\u03c9']

BTW, I found that an uncommon unicode that we also support is:

'OHM SIGN' (U+2126)
SI unit of resistance, named after G. S. Ohm, German physicist preferred representation is U+03A9

The lowercase is the same for:

'GREEK CAPITAL LETTER OMEGA' (U+03A9)

So the above code covers both.

Problems when using lowercase names in COLUMN_ORDER

The documentation says this section (as others) are case-insensitive.
The code does some effort, but is not enough.

Columns generated in the CSV:

references,value,part,description,Description,Part,References,Value

But we should get:

references,value,part,description

The patch to fix it isn' t trivial. A working solution is on the following branch: fix_column_case

And was merged into my fork as PR #10

I'm not submitting a PR because it will collide with other PRs I submitted. I can submit it after they are merged.

Generate the netlist in xml format

Hi,

I'm trying to run KiBom from the command line with no GUI interaction at all. I noticed that in projects where I haven't run the BOM from the GUI, there's no xml netlist (at least on windows with Kicad 5.1.4).

Is there a way to generate that netlist so I can run KiBom from the command line? The alternative I see is runing the BoM at least once from the GUI, but that's prone to errors as it would be very easy to forget to update the XML if something changes in the schematic, and you would be generating an outdated BoM

Multiple Config values for same part

My schematic is organized by manufacturer (manf) and manufacturer part number (panf_pn) fields. Also we are using the Config field for multiple configurations (-no_batt, -no_12V, -no_5V)
Occasionally we have a part (example resistor Manf = Yageo, Manf_PN= 08051k) that is used in multiple places and has multiple configs. Some update in the last year now prevents parts with 'conflicted_field' to no longer be printed to the BOM. Anyway to fix this?
Thanks!

KeyError

Even with a schematic that has only a single resistor from the standard library I get the following error.
KiCad is version 4.0.7 running under Windows 10, with the KiBOM version I downloaded on 30th August 2018.

Did I miss something or is this a real bug?

Thanks for the help

KiBOM Output from Bill of Material Window in KiCad

Run command:
python "C:/_owncloud/Documents/KiCad/KiBoM-master/KiBOM_CLI.py" "C:/_owncloud/Documents/KiCad/_dummy2/dummy.xml" "C:/_owncloud/Documents/KiCad/_dummy2/dummy"

Command error. Return code 1

Error messages:
Traceback (most recent call last):
  File "C:/_owncloud/Documents/KiCad/KiBoM-master/KiBOM_CLI.py", line 124, in <module>
    groups = net.groupComponents(components)
  File "C:/_owncloud/Documents/KiCad/KiBoM-master/bomlib/netlist_reader.py", line 422, in groupComponents
    g.updateFields(self.prefs.useAlt, self.prefs.altWrap)
  File "C:/_owncloud/Documents/KiCad/KiBoM-master/bomlib/component.py", line 471, in updateFields
    self.fields[ColumnList.COL_DESCRIPTION] = self.components[0].getDescription()
  File "C:/_owncloud/Documents/KiCad/KiBoM-master/bomlib/component.py", line 127, in getDescription
    return self.element.get("libsource", "description")
  File "C:/_owncloud/Documents/KiCad/KiBoM-master/bomlib/netlist_reader.py", line 190, in get
    ret = child.get(elemName, attribute, attrmatch)
  File "C:/_owncloud/Documents/KiCad/KiBoM-master/bomlib/netlist_reader.py", line 183, in get
    return self.attributes[attribute]
KeyError: 'description'

And here the xml file

<?xml version="1.0" encoding="UTF-8"?>
<export version="D">
  <design>
    <source>C:/_owncloud/Documents/KiCad/_dummy2/dummy.sch</source>
    <date>31/08/2018 08:43:49</date>
    <tool>Eeschema 4.0.7</tool>
    <sheet number="1" name="/" tstamps="/">
      <title_block>
        <title/>
        <company/>
        <rev/>
        <date/>
        <source>dummy.sch</source>
        <comment number="1" value=""/>
        <comment number="2" value=""/>
        <comment number="3" value=""/>
        <comment number="4" value=""/>
      </title_block>
    </sheet>
  </design>
  <components>
    <comp ref="R2">
      <value>330R</value>
      <footprint>Resistors_SMD:R_1206</footprint>
      <libsource lib="device" part="R"/>
      <sheetpath names="/" tstamps="/"/>
      <tstamp>5B88D4F0</tstamp>
    </comp>
  </components>
  <libparts>
    <libpart lib="device" part="R">
      <description>Resistor</description>
      <footprints>
        <fp>R_*</fp>
        <fp>R_*</fp>
      </footprints>
      <fields>
        <field name="Reference">R</field>
        <field name="Value">R</field>
      </fields>
      <pins>
        <pin num="1" name="~" type="passive"/>
        <pin num="2" name="~" type="passive"/>
      </pins>
    </libpart>
  </libparts>
  <libraries>
    <library logical="device">
      <uri>C:\Program Files\KiCad\share\kicad\library\device.lib</uri>
    </library>
  </libraries>
  <nets>
    <net code="1" name="Net-(R2-Pad1)">
      <node ref="R2" pin="1"/>
      <node ref="R2" pin="2"/>
    </net>
  </nets>
</export>

xlsx output issue

Using KiBoM_CLI from within KiCad can't output xlsx :
python "F:\programmes\KiCad\bin\scripting\plugins\KiBoM/KiBOM_CLI.py" "%I" "%O.xlsx"

Log :
ERROR Error writing XLSX output
ERROR Error writing variant 'None'

I'm on windows 10, I have installed XlsxWriter and I have no issue with other output formats.

Add unit testing

Create an example schematic file, and ensure that the KiBoM script functions as desired.

This testing process should also calculate code coverage.

TypeError: a bytes-like object is required, not 'str'

Errormessage:
Traceback (most recent call last):
  File "/home/thomas/Projekte/KiBoM/KiBOM_CLI.py", line 103, in <module>
    pref.Write(ini)
  File "/home/thomas/Projekte/KiBoM/KiBOM/preferences.py", line 205, in Write
    cf.write(configfile)
  File "/usr/lib/python3.5/configparser.py", line 916, in write
    self._sections[section].items(), d)
  File "/usr/lib/python3.5/configparser.py", line 920, in _write_section
    fp.write("[{}]\n".format(section_name))
TypeError: a bytes-like object is required, not 'str'

Variants with "-" prefix are DNF regardless of variant specified

There seems to be a bug in the "exclude-from-variant" feature. Any part with the - prefix in the fit_field is ignored, regardless of the variant configuration passed.

Here's an example of the issue:

Ref fit_field
C1
C2 -foo
C3 +foo

With no variant flag, only C1 appears. With the option -r foo passed, C1 and C3 appear.
From the readme, I'd expect C1 and C2 to appear with no flag passed, right?

I'm running Manjaro Linux with KiCAD 5.1.0, Python 2.7.16, and the latest version of KiBOM as of writing (e4df1e8). I've also attached the example project I used to test this. test-project.zip

group_connectors option doesn't work

I cannot get the group_connectors option in the bom.ini to work.
As I understand it "value" field is ignored for components who is of type "connector".
I don't know the exact mechanism, but trying to search for the group_connectors option ended in the preferences.py file.
Also if I look in your example schematic you have 2 connectors (P1 and P2), and they are having separate lines in your example .html and .csv output files.
Do you have to give connectors a special field to mark them as "connectors"??

Loss of descriptions in the BOM when a component name includes a '/'

In custom atomic parts libraries, some components have a value that includes the '/' character. In this case, KiBoM has difficulty in finding the description of many components included in the same files (.lib and .dcm), even if the component value do not have a '/'.

Faulty librairies are easily find using grep:
$ grep 'F1 "' *.lib | grep '/'
$ linear_voltage_regulator.lib:F1 "SPX1117M3-L-3-3/TR" -600 -375 50 H I L TNN
$ linear_voltage_regulator.lib:F1 "SPX1117M3-L/TR" -605 -505 50 H I L TNN
$ thermistor_ptc.lib:F1 "MF-MSMF110/16-2" -750 -475 50 H I L TNN

This limitation was not in the KiBoM master branch in October 2018... or it can be relative to software upgrade on my side. In october, I was running on MX Linux 17.1 with KiCad 4.0.7 and Python 2.7

Presently, I'm running MX Linux 18.2 with KiCAD 5.0.1, Python 3.7.0, and the latest version of KiBOM as of writing (e4df1e8)

Command error. Return code 1 [KiCad 5.1.5] [MacOS 10.15.4]

I'm trying to set up kibom for the first time. I want to run it from within kicad Bill of Material window. The first issue I ran into is that, contrary to readme, I could not find any file "KiBOM_CLI.py". So instead I selected main.py when adding the kibom plugin.

When I run python "/Users/user1/Library/Preferences/kicad/scripting/KiBoM/kibom/__main__.py" "%I" "%O" I get Command error. Return code 1 Error messages: Traceback (most recent call last): File “/Users/peer/Library/Preferences/kicad/scripting/KiBoM/kibom/__main__.py”, line 26, in <module> from .columns import ColumnList ValueError: Attempted relative import in non-package and no output

If I instead add the plugin by selecting init.py and running "/Users/peer/Library/Preferences/kicad/scripting/KiBoM/kibom/__init__.py" "%I" "%O I see a success message and eeschema xml netlist created in project directory.

Please help me set up KiBoM.

elide leading white space in values

I tried uploading my bom.csv to Digikey using their "BOM Manager" web app. My file included leading white space in my "Digikey Part Number" (or "SKU") column (my bad, probably faulty cut-and-paste from Digikey catalog to KiCad) and Digikey failed to find a match. So the request is: eliminate leading whitespace on values.

I would have thought Digikey would ignore it. In the Digikey app, one can easily delete the whitespace and find a match, its not a big problem.

I might have a chance to fix the issue before ordering my next board.

Ignore virtual components

Virtual footprints should be ignored by default. I suggest a flag (-a) to show all.
For example, I have a footprint that is a logo. It should not be on BOM because I don't need to by a logo :)

add support for showing sheetpath in BOM

Is it possible to add a sheetpath column to the BOM? This could be useful for a cost analysis on individual circuits/sheets in your design.

The column would contain the sheetpath that is displayed at the bottom right of every sheet (see picture below).

image

Kibom bom folder -d argument not working.

Hello,
First, thank you and congratulation for your great work !

I use Kibom on Ubuntu (16.04) and Python 2.7.

I'm not able to use -d argument to create the bom file in a specific
project folder.
I use the command : python -m kibom -d bom "%I" "%O.csv"
The directory name is "bom".

I installed version with pip.
I tried also latest version 1.7.1pre but there is same problem.
Thank you very much again !

Frex

Micro prefix

While testinng the code I found that:

PREFIX_MICRO = [u"μ", "u", "micro"]

Is using:
GREEK SMALL LETTER MU U+03BC GREEK SMALL LETTER MU μ

But, at least for me, is more common to use:
MICRO SIGN U+00B5 MICRO SIGN µ

So I'm using:

REFIX_MICRO = [u"μ", u"µ", "u", "micro"]

Which looks pretty lame, and I hope the cut & paste worked ;-), but includes both: the micro sign and the greek letter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.