aboutsummaryrefslogtreecommitdiff
path: root/src/ee/kicad
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/kicad')
-rw-r--r--src/ee/kicad/doit.py28
-rw-r--r--src/ee/kicad/pcb/__init__.py1
2 files changed, 17 insertions, 12 deletions
diff --git a/src/ee/kicad/doit.py b/src/ee/kicad/doit.py
index 577eb21..7273076 100644
--- a/src/ee/kicad/doit.py
+++ b/src/ee/kicad/doit.py
@@ -88,7 +88,7 @@ def task_kicad_sch_to_data_set():
with _dsm.create_rw(out_data_set, inputs=in_data_sets) as ds:
schematics = ee.kicad.read_schematics(sch)
for c in [c for c in schematics.components]:
- o = ds.get_object("kicad-schematic-component", c.timestamp)
+ o = ds.create_object("kicad-schematic-component", c.timestamp)
o.set("ref", c.ref)
o.set("ref-type", c.ref_type)
if c.has_ref_num:
@@ -116,24 +116,26 @@ def task_kicad_pcb_to_data_set():
in_data_sets = []
def action():
+ from ee.kicad.pcb import KicadPcb, Module
+
logger.debug("Parsing PCB {}".format(kicad_pcb))
with _dsm.create_rw(out_data_set, inputs=in_data_sets) as ds:
# [ds.delete(o) for o in ds.items(object_type="kicad-pcb-component")]
- pcb = ee.kicad.pcb.parse(kicad_pcb) # type: ee.kicad.pcb.KicadPcb
+ pcb = ee.kicad.pcb.parse(kicad_pcb) # type: KicadPcb
for _m in pcb.modules:
- m = _m # type: ee.kicad.pcb.Module
+ m = _m # type: Module
- o = ds.get_object("kicad-pcb-component", m.tstamp)
+ o = ds.create_object("kicad-pcb-component", m.tstamp)
ref_text = next((t for t in m.fp_texts if t.kind == "reference"), None)
o.set("reference", ref_text.value)
x, y, rot = m.at
- o.set("at-x", x)
- o.set("at-y", y)
- o.set("at-rot", rot)
+ o.set("placement-x", x)
+ o.set("placement-y", y)
+ o.set("placement-rotation", rot)
o.set("layer", m.layer)
return {
@@ -151,11 +153,13 @@ def task_kicad_create_component_data_set():
def action(targets, *args, **kwargs):
logger.info("targets={}, args={}, kwargs={}".format(targets, args, kwargs))
- with _dsm.create_rw(out_data_set, inputs=in_data_sets) as ds:
- items = ds.items()
- logger.info("Got {} objects".format(len(items)))
- for o in items:
- logger.info("processing {}".format(o.key))
+ with _dsm.create_ro(in_data_sets) as input:
+ with _dsm.create_rw(out_data_set) as output:
+ items = input.items()
+ logger.info("Got {} objects".format(len(items)))
+ for o in items:
+ ot = o.object_type
+ logger.info("processing {}:{}".format(ot.name, o.key))
return {
"basename": "kicad-create-component-data-set",
diff --git a/src/ee/kicad/pcb/__init__.py b/src/ee/kicad/pcb/__init__.py
index a4ad8ba..a8f96d7 100644
--- a/src/ee/kicad/pcb/__init__.py
+++ b/src/ee/kicad/pcb/__init__.py
@@ -7,6 +7,7 @@ def auto_str(cls):
return str({k: [str(x) for x in v] if isinstance(v, list) else str(v) for k, v in vars(self).items()})
cls.__str__ = __str__
+ cls.__name__ = cls.__name__
return cls