From aa9b9d0560b6515a05c2b2c94a75a50fde25e353 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 7 May 2019 12:41:42 +0200 Subject: kicad: Better export: * Allow unannotated parts in the export. * Export value and footprint too. --- src/ee/kicad/make_bom.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/ee/kicad/make_bom.py') diff --git a/src/ee/kicad/make_bom.py b/src/ee/kicad/make_bom.py index db4f80e..bec42de 100644 --- a/src/ee/kicad/make_bom.py +++ b/src/ee/kicad/make_bom.py @@ -98,6 +98,11 @@ class MakeBomStrategy(): def work(sch, out: Path, strategy: MakeBomStrategy, new_mode, pretty): + def strip(s): + s = (s or "").strip() + + return None if len(s) == 0 else s + if not new_mode: bom = to_bom_xml(sch) xml = ElementTree.tostring(bom, encoding="unicode") @@ -108,11 +113,27 @@ def work(sch, out: Path, strategy: MakeBomStrategy, new_mode, pretty): print(xml) else: parts = PartDb() - components = to_bom(sch) + components = to_bom(sch, require_ref=False) for c in components: xml = types.Part() part = Part(xml) - part.add_schematic_reference(c.ref) + + if c.has_ref_num: + part.add_schematic_reference(c.ref) + + value = strip(c.value) + if value: + part.facts.add(uris.make_fact_key("value"), value) + + footprint = strip(c.footprint) + if footprint: + part.facts.add(uris.make_fact_key("footprint"), footprint) + + i = footprint.find(":") + if i >= 0: + lib, footprint = footprint.split(":") + part.facts.add(uris.make_fact_key("kicad-schematic-library"), lib) + part.facts.add(uris.make_fact_key("kicad-schematic-footprint"), footprint) part = strategy.process_part(c, part) -- cgit v1.2.3