Skip to content

Commit f918435

Browse files
committed
Add kicad 7 native dnp field support
Fixes #361
1 parent 5beb871 commit f918435

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

InteractiveHtmlBom/ecad/kicad.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ def get_extra_field_data(self, file_name):
3737
@staticmethod
3838
def get_footprint_fields(f):
3939
# type: (pcbnew.FOOTPRINT) -> dict
40+
props = {}
4041
if hasattr(f, "GetProperties"):
41-
return f.GetProperties()
42+
props = f.GetProperties()
4243
if hasattr(f, "GetFields"):
43-
return f.GetFieldsShownText()
44-
return {}
44+
props = f.GetFieldsShownText()
45+
if "dnp" in props and props["dnp"] == "":
46+
del props["dnp"]
47+
props["kicad_dnp"] = True
48+
return props
4549

4650
def parse_extra_data_from_pcb(self):
4751
field_set = set()

InteractiveHtmlBom/ecad/kicad_extra/netlistparser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def get_extra_field_data(self):
2121
fields = None
2222
datasheet = None
2323
libsource = None
24+
dnp = False
2425
for f in c[1:]:
2526
if f[0] == 'ref':
2627
ref = f[1]
@@ -30,6 +31,9 @@ def get_extra_field_data(self):
3031
datasheet = f[1]
3132
if f[0] == 'libsource':
3233
libsource = f[1:]
34+
if f[0] == 'property' and isinstance(f[1], list) and \
35+
f[1][0] == 'name' and f[1][1] == 'dnp':
36+
dnp = True
3337
if ref is None:
3438
return None
3539
ref_fields = comp_dict.setdefault(ref, {})
@@ -41,6 +45,9 @@ def get_extra_field_data(self):
4145
if lib_field[0] == 'description':
4246
field_set.add('Description')
4347
ref_fields['Description'] = lib_field[1]
48+
if dnp:
49+
field_set.add('kicad_dnp')
50+
ref_fields['kicad_dnp'] = True
4451
if fields is None:
4552
continue
4653
for f in fields:

InteractiveHtmlBom/ecad/kicad_extra/xmlparser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ def get_extra_field_data(self):
3434
name = f.attributes['name'].value
3535
field_set.add(name)
3636
ref_fields[name] = self.get_text(f.childNodes)
37+
for f in c.getElementsByTagName('property'):
38+
if f.attributes['name'].value == 'dnp':
39+
field_set.add('kicad_dnp')
40+
ref_fields['kicad_dnp'] = True
3741

3842
return list(field_set), comp_dict

0 commit comments

Comments
 (0)