Skip to main content

BOM generation

Bill-of-materials generation creates a list of the components that used in the design. The components in the list are often grouped together if they have the same manufacturer part number. To generate the BOM, provide the -b [output file path] parameter to the circuitscript CLI tool. The BOM will be generated as a .csv file

BOM setup

There are two properties that determine how the BOM is generated:

  • document.bom.columns sets the component parameters that will be displayed in the BOM
  • document.bom.group_by sets how components are grouped. Components with the same parameter meter value will share the same line in the BOM.

Example:

from std import *
document.bom.columns = ["refdes", "mpn", "manufacturer", "footprint", "description", "DNI"]
document.bom.group_by = ["mpn", "manufacturer", "DNI"]

v5 = supply("5V")
gnd = dgnd()

at v5
wire down 100
add cap(100n)
..mpn = "CL05B104KP5VPNC"
..manufacturer = "Samsung Electro-Mechanics"
wire down 100
to gnd

at v5
wire down 100
add cap(100n)
..mpn = "CL05B104KP5VPNC"
..manufacturer = "Samsung Electro-Mechanics"
wire down 100
to gnd

at v5
wire down 100
add res(10k)
..mpn = "RC0402JR-0710KL"
..manufacturer = "Yageo"
wire down 100
to gnd
5V12C1100nGND5V12C2100nGND5V12R110kGND

The output BOM csv file:

Refdes,Mpn,Manufacturer,Footprint,Description,DNI
R1,RC0402JR-0710KL,Yageo,Resistor_SMD:R_0402_1005Metric,RES 10k OHM 0402,
"C1, C2",CL05B104KP5VPNC,Samsung Electro-Mechanics,Capacitor_SMD:C_0402_1005Metric,,

Parameter assignment rules

Component parameters can be directly assigned for each component as shown in the example above. However, in large designs with many components, this is tedious to maintain and change when MPN/manufacturer change are needed.

Instead of manually setting parameters for each component, rules can be used to assign parameters.

from std import *

v5 = supply("5V")
gnd = dgnd()

at v5
wire down 100
add cap(100n)
wire down 100
to gnd

at v5
wire down 100
branch:
wire down 100
add cap(100n)
wire down 100
to gnd

branch:
wire right 400 down 100
add cap(100n)
wire down 100
to gnd
branch:
wire right 800 down 100
add res(10k)
wire down 100
to gnd

# Parameter assignment rules
set: "mpn", "manufacturer":
type: "res", size: "0402", value:
10k: "RC0402JR-0710KL", "Yageo"
type: "cap", size: "0402", value:
100n: "CL05B104KP5VPNC", "Samsung Electro-Mechanics"
5V12C1100nGND5V12C2100nGND12C3100nGND12R110kGND

In the example above, the following rules are defined:

  1. If component is type res (resistor), has a size parameter of value 0402 and a value parameter of value 10k:
    1. assign mpn to be RC0402JR-0710KL
    2. assign manufacturer to be Yageo
  2. If component is type cap (capacitor), has a size parameter of value 0402 and a value parameter of value 100n:
    1. assign mpn to be CL05B104KP5VPNC
    2. assign manufacturer to be Samsung Electro-Mechanics

The output BOM csv file:

Refdes,Value,Mpn,Manufacturer,Footprint
R1,10k,RC0402JR-0710KL,Yageo,Resistor_SMD:R_0402_1005Metric
"C1, C2, C3",100n,CL05B104KP5VPNC,Samsung Electro-Mechanics,Capacitor_SMD:C_0402_1005Metric

Creating parameter rules

The set command starts with the name of the parameters that should be assigned. Multiple set commands may be defined at any point in the code but later set commands override earlier set commands.

The following example creates a rule that assigns the mpn and manufacturer parameter of components:

set: "mpn", "manufacturer"

Rules are defined in <parameterName>: <targetValue> pairs, these can be merged with commas to reduce the indentation needed.

The parameter value(s) to be assigned follows the last rule seperated by a colon. If there are multiple parameters to be assigned, each value is separate by commas.

The following parameter rules are all equivalent and perform the same parameter assignment.

# 2 parameters to be assigned
set: "mpn", "manufacturer":
# rules
type: "res", size: "0402", value:
10k: "RC0402JR-0710KL", "Yageo" # set first parameter, then second parameter
# 2 parameters to be assigned
set: "mpn", "manufacturer":
# rules
type: "res":
size: "0402":
# final rule and values to be assigned
value: 10k: "RC0402JR-0710KL", "Yageo"
# 2 parameters to be assigned
set: "mpn", "manufacturer":
# rules
type: "res", size: "0402":
value: 10k: "RC0402JR-0710KL", "Yageo"