Cannot generate csv BOM

KiCad 7.0.2
I am in the schematic editor and need to generate a BOM much like I have in the past with KiCAD 6.x
I only see 2 options now so I select “bom_csv_grouped_by_value_with fp”
This does not generate a CSV, only an HTML. I need the CSV as stated for submission to my vendor (jlcpcb).

What am I don’t wrong here?
thanks
Fritz

It’s not HTML, it’s actually XML, and it’s not the final output, just the intermediate file that eeschema feeds to the Python script.

I tried the same Python script and it exited in a error. Possibly it hasn’t been maintained. There is a JLCPCB Fabrication Toolkit plugin for generating the production outputs they need so this might be a better choice.

So you are saying there is no way to generate a BOM with the present version?
The fab vendors require this-

I will look for the toolkit when I get a chance
thanks!
fritz

I just tried with an old v6 project and it worked.

I saved the schematica and pcb to migrate them to v7 and it worked too, maybe you have some funky characters ?


Application: KiCad Schematic Editor x64 on x64

Version: 7.0.2, release build

Libraries:
	wxWidgets 3.2.2
	FreeType 2.12.1
	HarfBuzz 6.0.0
	FontConfig 2.14.1
	libcurl/7.88.1-DEV Schannel zlib/1.2.13

Platform: Windows 10 (build 19045), 64-bit edition, 64 bit, Little endian, wxMSW

Build Info:
	Date: Apr 15 2023 19:18:27
	wxWidgets: 3.2.2 (wchar_t,wx containers)
	Boost: 1.81.0
	OCC: 7.6.3
	Curl: 7.88.1-DEV
	ngspice: 40
	Compiler: Visual C++ 1934 without C++ ABI

Build settings:
	KICAD_SPICE=ON

No, I’m saying that the transformer script you tried also failed for me, and I have no desire to investigate it.

You can still use the old XSLT transformer (provided you have the xsltproc program which is not part of KiCad) following the instructions at JLCPCB to first download an XSLT script last modified by arturo182. Be careful, the JLCPCB site contains lots of old information which only apply to older KiCad or Python versions.

There is actually a plethora of BOM and CPL generation scripts written in Python, just do a searh and you will find at least a couple on Github. The Benny Megish one is in the PCM though.

Just updated to 7.0.2 from 7.0.1 and tried this, works for me. You obviously did click the Generate button ?

FYI - if you have a PCB, you can:

File>Fabrication_Outputs>BOM

It outputs a .CSV

Ok, I took a quick look at the Python error I got. It’s actually the author of the script being too adventurous in using new Python features.

$ python3 /usr/share/kicad/plugins/bom_csv_grouped_by_value_with_fp.py foo.xml foo.csv
Traceback (most recent call last):
  File "/usr/share/kicad/plugins/bom_csv_grouped_by_value_with_fp.py", line 69, in <module>
    refs = refs.removesuffix(', ')
AttributeError: 'str' object has no attribute 'removesuffix'

removesuffix is a string method that was added in Python 3.9. My distro’s version is 3.6.

1 Like

You may be correct, I can’t say. But, I’m running Kicad v6.11 and Python 3.9.12.

The CSV works fine (in fact, all of my BOM generators work fine…)

ADDED:
For curiosity… your error message points to Line#69

That line in my “bom_csv_grouped_by_value_with_fp” does Not contain an Error Clause.

However, line#69 in my “bom_csv_grouped_by_value” does (yes) contain an Error Clause.

And, still works fine… (last two screenshots)

Thanks for the investigation here–I am not sure I have 7.02 set up properly. In the past when I upgraded from 4, 5, and 6, it seems as though the BOM feature was set up automatically. Apparently not in this case

I am indeed pressing the “Generate” button but I am still showing a 6.0 module:
python: can’t open file ‘C:\Program Files\KiCad\6.0\bin\scripting\plugins\bom_csv_grouped_by_value_with_fp.py’

—is there an install note around here on WHERE to download the BOM 7.02 software, and WHERE to place it in the KiCAD files?

My understanding is that for generating the BOM from the PCB feature I need to select Tools:External Plugins: Refresh Plugins after putting the correct modules in the correct places.

Thanks
Fritz

You can look at the correct path in my screenshot (you seem to be in windows) and the the ‘+’ sign and add the correct script to the list.

I know Nothing about v7 except that, like every Kicad release, I wait 6 months before Upgrading and I upgrade only if the Posts (re bugs) is no longer overwhelming (to my little brain).

Thus, my Plugins for BOM are in same location and as you see in screenshot above, I have several Custom BOM’s, including HTML with user Text input panel (via web Browser). Also (and irrelevant) to get a nicely formatted output, I load the CSV’s in Libre’s Spreadsheet (Calc) and run a Macro I made via ‘Watch-me-do’ feature in Calc).

Re where to place whatever BOM code you download; just place it in the same location showing your current BOM creating codes…

BOM from PCB: The code to do it is a Stock Feature so, I did Not need to do anything except Click…

OK–I looked in the “Program Files” directory as some of you have listed and all of the 7.0.2 modules were there–but for some reason the 7.0.2 eschema editor was pointing to the old (and now removed) 6.x.x files. I did a “reset” (again) and now everything works fine.
Probably something went wrong in my install (a lot of files running around) but I am good now.

Regarding the mentioned Python issues, I have used it for about 10 years, but I never understood what was wrong with C++. In the process of reinventing this I indeed have had lots of problems with nothing working in Python from month to month—They seem to have issues converging on a long lasting version and it has been a constant problem or “rev roulette” in our lab for our hired computer scientists. I continue to use C++ when I can but unfortunately a lot of important modules are now written in python–

thanks for all the help
Fritz

1 Like

Nice catch. I’ll try and fix that tonight.

(Ref Bugfix: remove trailing comma after last ref (c5d7e447) · Commits · KiCad / KiCad Source Code / kicad · GitLab)

You should just be able to select that script, look in the “command line running the generator” box at the bottom, and change “6.0” to “7.0”

Looks like while your Python is new enough, your bom_csv_grouped_by_value_with_fp is a version that predates the problematic modification in question.

Apples and oranges. More coders are able to write in a scripting language like Python than C++, and scripts are more easily cross-platform. The trap is that authors have to be aware of what features they are using and whether their target audience has a suitable version. This requires discipline. Authors have to say, ok, the interpreter version we are targetting is say 3.6 (because people may be running LTS Linux distros for example). The problem is more evident in Python because of the ease with which new features can be added to the language.

But sometimes there is no easy way of getting some distributed Python software to work with an older interpreter. For example I had to run some speech to subtitle ML software using an appimage for Python 3.9 on my distro.

Thanks. According to a web tute, the portable way to remove the suffix is by using endswith and string slicing.

1 Like

I went a slightly different way: Fix BOM script compatibility with python 3.8 and below (!1598) · Merge requests · KiCad / KiCad Source Code / kicad · GitLab

3 Likes

Just as info, you REALLY owe it to yourself to look at JLCPCB Tools by Bouni for KiCad.

Workflow without JLCPCB Tools:

  • Export BOM CSV from Schematic
  • Hand-edit CSV with LCSC part numbers you have to research, reshuffle and rename columns, and then save as XLSX to preserve formatting. Delete rows of parts you don’t want placed. If you ever need to change the BOM, you’ll have to redo all this work.
  • Export POS/CPL from PCBNew
  • Rename file to CSV, hand-edit, reshuffle and rename columns, and then save as XLSX to preserve formatting. If you ever need to reexport the CPL file, you’ll have to redo all this work.
  • Export Gerbers from PCBNew, making sure you have all filename, layer, and drill settings correct.
  • Collect everything and upload it
  • See in the JLCPCB.com preview that Rotations are off, so correct these on the website.
  • NOTE: If you ever need to reorder this board, you’ll have to do the Rotations step again.

Workflow in JLCPCB Tools:

  • Open JLCPCB Tools in PCBNew
  • Use the search engine to assign LCSC parts to symbols.
  • Check and uncheck BOM and POS for every part as desired.
  • Rotate parts 90/180 which will be saved for that part forever (even future projects).
  • Click one button to export Gerbers, CPL, and BOM, all properly formatted.
  • Upload to the website. If you see any rotation or part problems, just change them in JLCPCB Tools and reexport as all the above workflow is saved permanently with the project!!