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.columnssets the component parameters that will be displayed in the BOMdocument.bom.group_bysets 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
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"
In the example above, the following rules are defined:
- If component is type
res(resistor), has asizeparameter of value0402and avalueparameter of value10k:- assign
mpnto beRC0402JR-0710KL - assign
manufacturerto beYageo
- assign
- If component is type
cap(capacitor), has asizeparameter of value0402and avalueparameter of value100n:- assign
mpnto beCL05B104KP5VPNC - assign
manufacturerto beSamsung Electro-Mechanics
- assign
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"