SchrodingersGat / KiBoM

Configurable BoM generation tool for KiCad EDA (http://kicad.org/)
MIT License
350 stars 95 forks source link

Feature Request: Set new DNP field based on configured variant #188

Open myamigo opened 11 months ago

myamigo commented 11 months ago

Thank for this script. It's very useful!

I'm wondering if the following could work as a way to better leverage support for the new DNP field in symbols.

Rather than including the new DNP field as an input to your script as it does now with the new code added to isFitted(() could you instead set that field based on the DNP status as determined by the other tests in the same function (under # Variants logic). With this change when isFitted() exits the component's DNP flag will be explicitly set or cleared based on the variant field settings +BLAH, -BLAH.

After running the script for a particular variant the schematic would then visually display the DNP status for every component in the design.

I tried to figure out where and how to hack some changes in to test this but I got stuck not knowing how to set a field attribute.

Thank again!

SchrodingersGat commented 11 months ago

@myamigo I feel that this idea is somewhat out of scope for the project, but if you come up with a way of implementing this seamlessly, let me know!

set-soft commented 11 months ago

Hi @myamigo ! Take a look at KiBot, it can generate printed outputs of each variant, you can even generate new schematics and PCBs with the variants applied. KiBot can use KiBoM to generate the BoMs, as a quick start option, but also implements a BoM output that is strongly inspired (read: I took a lot of @SchrodingersGat good ideas and code) that goes even farther. It supports KiBoM style variants, but also KiCost and iBoM variants. It runs on Linux, WSL and docker images. Not plain vanilla Windows (i.e. without enabling WSL or without installing docker).

set-soft commented 11 months ago

Hi @SchrodingersGat !

with a way of implementing this seamlessly, let me know!

Lamentably the Python schematic API (in the roadmap for 6.0) was never implemented, so you must deal with the schematic format, which isn't well documented. KiBot can read and write schematic for KiCad 5, 6 and 7 (even for 7.99). So it can load a schematic, apply the variants to the DNP attribute and store it to disk. Is really complex.

myamigo commented 11 months ago

Hi @SchrodingersGat, I will share whatever I come up with.

I was hoping to learn how to set a field in a symbol and since your script touches every component I figured the simplest approach would involve modifying your scripts. If you are able to suggest a command that would allow me to set a field in the symbol rather than just reading then I'll work with that. Otherwise it seems I'll have to complete a deep dive into KC Python scripting.

Thanks for the KiBot suggestion @set-soft. I had looked at this previously but I am on Windoze and while I have WSL installed I am not quite prepared to commit to the effort required to get fully setup in that environment.,

Thank you both.