Outils pour utilisateurs

Outils du site


Table des matières

KiCad symbols

Logo PTL

PCB symbol

The KiCad supplied vectorisation tool to create logos converts bitmaps to vector graphics. Our logo is already a vector graphic and thus could be converted directly without any rasterising-vectorising artefacts. - Well, quite. SVG and KiCad are not fully compatible with respect to supported path operations. Essentially KiCad paths need to be straight line segments without holes. To cut a long story short, this is how one may do it:

  1. Convert SVG to PDF: use Inkscape, Save as PTL.pdf
  2. Convert PDF to PS:
    pdf2ps PTL.pdf > PTL.ps
  3. Convert PS to gEDA PCB's format:
    pstoedit PTL.ps -ssp -f pcb -flat 0.01 > PTL.pcb

    Here the options mean:

    • -ssp: remove any holes in the paths, this actually makes sure that holes *are* preserved, at least visually
    • -flat 0.01: there are no round curves in the output, and this option just tells how well they should be approximated
  4. Run ruby script below to convert relevant part into .kicad_mod format:
    ./pcb2kicad.rb PTL.pcb  > PTL.kicad_mod
pcb2kicad.rb
#!/usr/bin/env ruby
 
paths=[]
path=[]
xmin=nil
xmax=nil
ymin=nil
ymax=nil
ARGF.each do |line|
  if line =~ /Polygon/
    if path.length>2
      paths<<path
    end
    path=[]
  elsif line =~ /^\s*\[.*\]/
    x,y=line.split(/[\[ \]]/)[1..2].map{|e| Float(e)}
    xmin=x if xmin.nil? or x<xmin
    xmax=x if xmax.nil? or x>xmax
    ymin=y if ymin.nil? or y<ymin
    ymax=y if ymax.nil? or y>ymax
    path<<[x,y]
  end
end
if path.length>2
  paths<<path
end
 
if xmax-xmin>ymax-ymin
  scale=25.4/(xmax-xmin)
else
  scale=25.4/(ymax-ymin)
end
 
puts '(module PTL (layer F.Cu) (at 0 0)'
paths.each{|path|
  puts '(fp_poly'
  puts '  (pts '
  path.each{|point|
    puts "    (xy #{scale*(point[0]-xmin)} #{scale*(point[1]-ymin)})"
  }
  puts '  )'
  puts '  (layer F.SilkS)'
  puts '  (width 0)'
  puts ')'
}
puts ')'
fabrication/electronics/kicad_symbols.txt · Dernière modification: 2015/04/27 14:58 par rossen