KiCad BOM plugins (was KiCad BOM in Markdown)

Well, I may have lied. I don’t remember changing that part of the code but when I look at the KiCad distributions’ scripts none of them do that. Instead you have for instance

bom_html_grouped_by_value.py:html = html.replace('<!--SOURCE-->', net.getSource())

Perhaps I was annoyed by the very long path names I end up with (my sch files mostly are about 10 levels below my home directory) and changed it to just print the file name. I don’t know why I didn’t use the os.path methods though. Maybe laziness.

I’ve changed the posted version to just use

md = md.replace('<!--SOURCE-->', net.getSource())

for people with less Byzantine file heirarchies.

1 Like

Thanks for the feedback. Looking at the output of net.getSource() was goign to be my next step…but…bedtime :smiley:

Changing that to “md = md.replace(’’, net.getSource())” did get it to run so that seems to have been the error.

I then took @fredrik’s advice and replaced “import re” with “import os.path” and the new line with:

md = md.replace('<!--SOURCE-->', os.path.basename(net.getSource()))

So now I just get the filename instead of the full path - which I agree is much cleaner :wink:

Thanks for the help guys.

1 Like

It’s not that big of a deal…but I did misspeak slightly. With kicad I actaully output SVG not PDF which I rather prefer working with. Not a huge deal…either format works in the end. And you’re 100% correct that one extra step (inverting) isn’t a big deal. But…I’m still in favor of avoiding any steps I can :smiley:

But this is far from the only factor - as you point out the free version of Eagle is really limited and while I have the full license I know most people don’t. The main reason I wanted to give Eagle a go is since I use f360 so much and the two are now so tightly integrated it seemed like it may be really nice for projects where I’m designing more than just a panel around a layout. Or even fancier panels where the board holds components that are attached to the panel.

And I would still rather have professionally made boards on some things and for that both packages are good at generating gerbers for the board houses. So one extra step outputting artwork for DIY fab isn’t the end of the world.

However, kicad is more accessible for more people and since I like to share what I do that is important to me. And kicad has nice things like @analogoutput’s markdown generator and the interactive BOM generator both of which are pretty slick. And kicad has improved so much over the past 5 years it gives me hope for it continuing to improve.

Unless I’m missing something this doesn’t seem to be the case anymore. The tutorials still seem to suggest it. But “Update from Schematic…” seems to have been vastly improved in recent versions. I saw complaints about it removing footprints that weren’t in the schematic - but that apparently has been addressed. Otherwise so far it seems to be doing a great job and I haven’t had to manually export a netlist once. (I did initially since the tutorial I was following suggested doing it that way…but then I tried the update command and found it works to my liking and is much simpler.)

Oh, then I have to try this out this week-end !
The only other thing I do regularly that bother me is the component rotation when the labels (name and value) don’t rotate around the same center… As I do this mostly with resistors and caps, I now create a rotated copy of each and adjust the labels, then copy it instead of adding a new one.
Otherwise, I’m reasonably satisfied with Kicad, especially for a free software.

Def want to use pythons native os paths for compatibility.

You shouldn’t nessisarily have to use regex patterns either since that module has functionality to test for existence of files.

I’d have to look after work though, unless this gets sorted before then.

I have no experience with kicad, but Im really interested in starting soon.

1 Like

I wrote the script for my own use, so I cared nothing for compatibility: Anything that worked for me was good enough. Later someone asked about it so I posted it… I make no claims it’ll work for everyone!

But I did put the os.path fix in the posted version after @juggle reported success with it.

3 Likes

someone make a video of this on windows… :stuck_out_tongue:
i still havent gotten it to work.

1 Like

lol isnt that the way it goes. You make something for yourself then everyone wants to use it, then suddenly you are supporting a tool.

@d42kn355, i still havent opened kicad, but im going to be having some time off soon and i plan to dig into it.

3 Likes

Which part are you stuck on? Not sure I could do a very helpful video…but I can try to walk you through it since I juts got it working on windows with the small changes we just discussed.

1 Like

Or saying “Support LOL no”…

3 Likes

Support LOL no

But

Watched this video today:

and it looked pretty interesting, but I decided KiBoM is rather more elaborate than I need (and if I did use it I’d want to write a Markdown output module for it), so instead I just modified my script to do similarly: If a component has a field named “Config” which contains “dnf” it doesn’t get written to the BOM.

(I think in KiCad 6.x there will be a check box to leave components out of the BOM, and one to leave them off the PCB as well.)

I also added a more idiosyncratic feature: Most of my KiCad projects are in subdirectories of a git directory that contains a Docs directory, e.g.:

Sequencer
Sequencer/Panel
Sequencer/Software
Sequencer/Software/sequencer
Sequencer/Hardware
Sequencer/Hardware/lmnc_8_step_seq
Sequencer/Docs

where the KiCad project is in Sequencer/Hardware/lmnc_8_step_seq. I made a modification where if the plugin command ends with ‘–todocs’ (from KiCad’s BOM dialog: ‘python3 “/path/to/plugins/bom_group_md.py” “%I” “%O_bom.md” --todocs’) then the BOM file gets written into Sequencer/Docs instead of Sequencer/Hardware/lmnc_8_step_seq (more generally, it climbs the directory tree looking for a directory containing a directory named Docs, and sticks the output file there). Probably useful to no one but me, but that’s who I wrote the script for.

It’s in GitHub - holmesrichards/bomscripts: KiCad BOM scripts .

I think this requires Python3, by the way.

4 Likes

Thanks @Sonosus for suggesting this:

The BOM contains a Description for each component. That description comes from a field you can edit in the Symbol Editor, but not directly in the symbol properties pane. You can click the Edit Symbol... button in that pane to edit the description for that particular component, but it involves several clicks and menu selection and opening and closing the Symbol Editor.

So in the latest version of mdbom, if there is a custom field called Description, then it overrides the regular description in the BOM. From the properties pane you only have to click the + button, enter “Description” under Name, and enter the description under Value. Or you can do it in the bulk edit symbol fields pane, even easier if you want to change descriptions for multiple components.

1 Like

I think it’s aggravating to find your resistors or make up a resistor order when you have a BOM with a big list of resistors grouped by value but sorted by reference, so the values jump around at random. I finally got aggravated enough to do something about it. I’ve moved the mdbom repo to GitHub - holmesrichards/bomscripts: KiCad BOM scripts and added another plugin called bom_resistors.py. This just lists the resistors in a text file, sorted by value. With no options it sorts from smallest resistance to largest, e.g.

image

With option --xxy it internally converts the value to 3 digits (2 significant figures plus # zeroes, e.g. 124 for 120k) and sorts by that:

image

(which is the order I store my resistors in). If it finds a value it doesn’t understand it sticks it at the bottom of the list.

7 Likes

actually I find the black back ground of the github BOM file more annoying . have to do an extra step [ photo shop] to turn it white before printing or am I missing something ?

???


is there a setting somewere for this ?

1 Like

found it [ day setting ] in the preferences .


all this time I thought that just how it looked LOL.

3 Likes

“day setting”? I found https://github.com/settings/appearance . Same thing?

Remember, folks, dark mode is for suckers.

2 Likes

" dark mode is for suckers " LOL .
I find the dark setting is easier on the eyes .
yeah it is a setting in the appearance section of settings .
I never set it though , it just went with what i use on other pages .