KiField icon indicating copy to clipboard operation
KiField copied to clipboard

Add quantity column

Open ryanfobel opened this issue 5 years ago • 5 comments

When generating a BOM from a schematic, you can group components with the same value using the -g or --group command line switch, but in this case, I would expect a "Quantity" column to include the number of components. Is there a way to generate this automatically?

ryanfobel avatar Nov 17 '20 15:11 ryanfobel

I'd be up for taking a whack at adding this. Is there a preference for branch naming? Do I need to be added as a contributor, or is there a different way for me to share proposed changes?

psheph avatar May 27 '21 01:05 psheph

  1. Fork this repo.
  2. Make changes to the development branch.
  3. Issue a PR.

I'm not sure what this feature actually accomplishes since you can see the list of references in each group. The only time you would need the quantity is if there were a large number of identical parts so the reference list would be too large for the spreadsheet cell. But do you really care about the exact number?

xesscorp avatar May 27 '21 20:05 xesscorp

But do you really care about the exact number?

Heck yeah! :joy:

I'm not sure you are aware of how many ways people want to use KiField! For example, our intern, @jerryhgoss, recently used KiField as a part of a project to download part metadata from Octopart, and then automatically push these properties back into the schematic. (this doesn't require the qty field, of course) https://github.com/jerryhgoss/Octopart_KiCad_Integration

The motivation for exporting qty is to generate better BOMs for sending to CMs. The native export capability of KiCad v5 won't group by properties such as "DNP", but KiField will. The fact that KiField uses - notation for lists of consecutive reference designators makes for a beautiful BOM, but makes it harder to count the qty in a script or Excel. I've been poking around, and I think I have an idea where to stick the accumulator during grouping. At least for one or two file formats.

psheph avatar May 27 '21 20:05 psheph

I like your first application; that's what KiField is for.

I'm a bit leery of using KiField in a BOM-type application. That kind of happened with my KiCost app and I don't think it was a good idea. Still, it's FOSS so go ahead and try! It wouldn't be the first time I was wrong.

I'm doing some work on KiField to support KiCad V6 schematic and library formats, so be aware the source is changing. It may require some manual effort on my part to reconcile your changes and mine.

xesscorp avatar May 29 '21 15:05 xesscorp

I've put together a prototype implementation that adds a new command line flag:

  --addquantity, -aq    Add 'quantity' column when when components are grouped.

If the flag is passed, a column called quantity is added (or updated if it already exists) when the --group flag is also passed. Thinking about this some more, I wonder if this flag should also accept the column name as a parameter?

If anyone else would find this useful, I'd be happy to write tests, a pull request, etc.

ryanfobel avatar Oct 26 '21 20:10 ryanfobel