Hi all, my name is William.
I am new to KiCad.
I am an hardware design engineer, i have a broad level of knowledge in electronics and i can also do c programming.
I have experience with several schematics & pcb CAD programs like Cadence Orcad , Altium , Protel.
And i would like to familiarize myself with KiCad.
For work purposes and to make pcb’s for the hobby.
I am very fond of the pretty intuitive and simple user interface.
I would like to create a copy of the python script to make a version that generates extra fields in the csv script. I am not a python wizard, i can write a script with some trial and error. But i am not able to understand how the kicad netlist reader functions or the kicad utils. I can ask friends and colleagues how to do python but in order to do so i need a basic understanding how the python script is retrieving the fields from the schematic .
It is about the python script : bom_csv_grouped_extra.py
See the end of the post for an excerpt.
Does anybody know how to do this ?
Seems like a standard question.
But i have no idea.
Thank you very much in advance.
William.
Excerpt form the python script :
"
@package
Output: CSV (comma-separated)
Grouped By: Value, Footprint, DNP, specified extra fields
Sorted By: Reference
Fields: #, Reference, Qty, Value, Footprint, DNP, specified extra fields
Outputs components grouped by Value, Footprint, and specified extra fields.
Extra fields can be passed as command line arguments at the end, one field per argument.
Command line:
python "pathToFile/bom_csv_grouped_extra.py" "%I" "%O.csv" "Extra_Field1" "Extra_Field2"
Import the KiCad python helper module and the csv formatter
import kicad_netlist_reader
import kicad_utils
import csv
import sys
Get extra fields from the command line
extra_fields = sys.argv[3:]
comp_fields = [‘Value’, ‘Footprint’, ‘DNP’] + extra_fields
header_names = [‘#’, ‘Reference’, ‘Qty’] + comp_fields
def getComponentString(comp, field_name):
if field_name == “Value”:
return comp.getValue()
elif field_name == “Footprint”:
return comp.getFootprint()
elif field_name == “DNP”:
return comp.getDNPString()
elif field_name == “Datasheet”:
return comp.getDatasheet()
else:
return comp.getField( field_name )
"