andete / madparts

A functional footprint editor.
GNU General Public License v3.0
80 stars 8 forks source link

Improve VAL and REF syntax while exporting to kicad #89

Closed andete closed 9 years ago

andete commented 9 years ago

As originally emailed:

I have a minor suggestion in the export section kicad.py.

I changed the code a bit to include VAL* and REF* like this:

# (fp_text reference MYCONN3 (at 0 -2.54) (layer F.SilkS)
#   (effects (font (size 1.00076 1.00076) (thickness 0.25146)))
# )
# (fp_text value SMD (at 0 2.54) (layer F.SilkS) hide
#   (effects (font (size 1.00076 1.00076) (thickness 0.25146)))
# )
def label(shape, layer):
  s = shape['value'].upper()
  t = "user"
  if s == "VALUE":
    t = "value"
    #l = [S('fp_text'), S(t), shape['value']]
    l = [S('fp_text'), S(t), "VAL**"]
  elif s == "NAME":
    t = "reference"
    l = [S('fp_text'), S(t), "REF**"]
  else:
    l = [S('fp_text'), S(t), shape['value']]
  if (('rot' in shape) and (fget(shape, 'rot') != 0.0)):
    l.append([S('at'), fget(shape, 'x'), fc(-fget(shape, 'y')),

fget(shape, 'rot')]) else: l.append([S('at'), fget(shape, 'x'), fc(-fget(shape, 'y'))]) if s == 'VALUE': l.append([S('layer'), S('F.Fab')])

l.append(S('hide'))

  else:
    l.append([S('layer'), S(layer)])
  dy = fget(shape, 'dy', 1/1.6)
  th = fget(shape, 'w', 0.1)
  l.append([S('effects'),
            [S('font'), [S('size'), dy, dy], [S('thickness'), th]]])
  return [l]

and so will produce a XXX.kicad_mod file like this:

module "MF563_FuseHolder" (layer F.Cu) (descr "TODO") (fp_text reference "REF" (at 0.0 -13.7) (layer F.SilkS) (effects (font (size 0.625 0.625) (thickness 0.1)))) (fp_text value "VAL" (at 0.0 13.7) (layer F.Fab) (effects (font (size 0.625 0.625) (thickness 0.1)))) (pad 1 thru_hole circle (size 2.4 2.4) (at 0.0 -10.9 0) (layers .Cu .Mask) (drill 0.8)) (pad 2 thru_hole circle (size 2.4 2.4) (at 0.0 10.9 0) (layers .Cu .Mask) (drill 0.8)) (fp_line (start -4.75 -13.0) (end 4.75 -13.0) (layer F.SilkS) (width 0.25)) (fp_line (start 4.75 13.0) (end -4.75 13.0) (layer F.SilkS) (width 0.25)) (fp_line (start 4.75 -13.0) (end 4.75 13.0) (layer F.SilkS) (width 0.25)) (fp_line (start -4.75 13.0) (end -4.75 -13.0) (layer F.SilkS) (width 0.25)))

The REF* and VAL* are replaced by Kicad to put in the values hooked into the PCB design of the user. Maybe there is a more elegant way to do this or this is not the correct way. Just though this may (or may not) be useful in the next madparts release.