Symbol in_bom/on_board flags are always True
I needed to customize the behaviour of S6.2 rule (value field must be visible) for my internal library for non-BOM symbol (use case: I don't want a value for test-points and mounting holes cluttering schematics).
I found out that in_bom flag has a value of no in sexpr data, but the parser always sets in_bom to True if it's found.
The following diff fixed this for me (also for on_board field):
diff --git a/common/kicad_sym.py b/common/kicad_sym.py
index e24b1a1..39a2c99 100644
--- a/common/kicad_sym.py
+++ b/common/kicad_sym.py
@@ -137,6 +137,15 @@ def _get_value_of(data, lookup, default=None):
return i[1]
return default
+def _get_flag(data, lookup, default=True) -> bool:
+ v = _get_value_of(data, lookup)
+ if v is None:
+ return default
+
+ if v == "no":
+ return False
+
+ return bool(v)
def _has_value(data, lookup) -> bool:
"""return true if the lookup item exists"""
@@ -1093,11 +1102,11 @@ class KicadLibrary(KicadSymbolBase):
# get flags
if _has_value(item, "in_bom"):
- symbol.in_bom = True
+ symbol.in_bom = _get_flag(item, "in_bom")
if _has_value(item, "power"):
symbol.is_power = True
if _has_value(item, "on_board"):
- symbol.on_board = True
+ symbol.on_board = _get_flag(item, "on_board")
# get pin-numbers properties
pin_numbers_info = _get_array2(item, "pin_numbers")