Interactive HTML BOM - Use "Description" as a field? [Resolved]

I’ve just been playing around with @qu1ck 's amazing Interactive HTML BOM plugin in KiCad v5.99 (https://github.com/openscopeproject/InteractiveHtmlBom). It works really well and I really like the fact that I can generate a netlist in the schematic and have all the component fields available to be shown.

However, I haven’t been able to figure out how to add the component “Description” as shown in the library. Has someone been able to do this successfully?

To clarify what I mean by “Description”:

Thanks in advance!

Description is not a part field, it’s a component field, in other words its immutable for component instance placed on schematic and is inherited from library component.

That’s why it’s not supported right now but a feature can be added as optional extra field in ibom.

However the method of parsing .net or .xml files for schematic fields will be deprecated soon since kicad 6 has schematic fields are imported into pcb data. Description isn’t imported though. I’ll see if kicad folks are open to importing that as well.

https://gitlab.com/kicad/code/kicad/-/issues/7783 if you want to upvote or follow along.

Thanks for the @qu1ck reply! I will thumbs up your issue for v7.

In the meantime might it be possible to use the legacy netlist file for this? I just had a look and it seems that the description field is transferred via the libsource token:

(comp (ref "EC2")
      (value "CON22")
      (footprint "Chapter 7:CON22 (finger)")
      (fields
        (field (name "My field") "FieldValue"))
      (libsource (lib "libraryname") (part "CONN-22WAY") (description "22 WAY EDGE CONNECTOR"))
      (property (name "My field") (value "FieldValue"))
      (property (name "Sheet name") (value "Sheet1"))
      (property (name "Sheet file") (value "sheet1.kicad_sch"))
      (property (name "Block name") (value "Counter"))
      (sheetpath (names "/Counter/") (tstamps "/5c38ec5e-4adc-44e9-bbb8-89c88e5a9485/"))
      (tstamp "211a131a-c988-4127-acfe-32100e7d63ee"))

Yes, the data is there so it’s possible, like I said. But I’m reluctant to add it if equivalent feature will not be available in v6 and I want to move away from parsing netlist file.

Ok I think I understand where you are coming from in terms of plugin maintenance. I have managed to get it working by editing the netlist parser. (By the way Kudos for the simplicity of the plugin: it does make it very easy to add to it!)

For the benefit of others reading this thread, I have been able to get this to work with some small changes to the file InteractiveHtmlBom/ecad/kicad_extra/netlistparser.py. The diff is below, as well as the full file attached for those not using git. All you need to do is replace the file and reload the plugin.

Click to expand diff
 InteractiveHtmlBom/ecad/kicad_extra/netlistparser.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/InteractiveHtmlBom/ecad/kicad_extra/netlistparser.py b/InteractiveHtmlBom/ecad/kicad_extra/netlistparser.py
index 724673b..d1c395b 100644
--- a/InteractiveHtmlBom/ecad/kicad_extra/netlistparser.py
+++ b/InteractiveHtmlBom/ecad/kicad_extra/netlistparser.py
@@ -20,6 +20,7 @@ class NetlistParser(ParserBase):
             ref = None
             fields = None
             datasheet = None
+            libsource = None
             for f in c[1:]:
                 if f[0] == 'ref':
                     ref = f[1]
@@ -27,12 +28,19 @@ class NetlistParser(ParserBase):
                     fields = f[1:]
                 if f[0] == 'datasheet':
                     datasheet = f[1]
+                if f[0] == 'libsource':
+                    libsource = f[1:]
             if ref is None:
                 return None
             ref_fields = comp_dict.setdefault(ref, {})
             if datasheet and datasheet != '~':
                 field_set.add('datasheet')
                 ref_fields['datasheet'] = datasheet
+            if libsource is not None:
+                for libField in libsource:
+                    if libField[0] == 'description':
+                        field_set.add('Description')
+                        ref_fields['Description'] = libField[1]
             if fields is None:
                 continue
             for f in fields:

Modified file attached:
netlistparser.py (1.7 KB)

The above makes a new field show up called “Description”:

1 Like

I looked at your diff and realized that I already have custom logic for datasheet field which is also not transferred to pcb. So my reasoning is moot and I probably am stuck with parsing netlist either way.

I’ll add description field too.

2 Likes

This is now in plugin upstream, works both for netlist and xml file.

1 Like

Thanks a lot! …and some more characters to reach the 20 character minimum