LoginSignup
7
0

KiCad PCB基板ファイルからfootprintライブラリを作る

Last updated at Posted at 2019-12-03

image.png

BLEトレーニングボードのアオノドンです。これをモジュールとして使えるようにフットプリントライブラリを作ります。

以下の記事を参考に
「Is there a way to convert whole PCB in new footprint?」
https://forum.kicad.info/t/is-there-a-way-to-convert-whole-pcb-in-new-footprint/6615/16

記事の中に貼ってあった
pcb_to_footprint.py
を試したところ、Python3で動作しませんでした。

なので書き換えて使えるようにしたものを公開します。
https://github.com/nanbuwks/kicad_pcb_to_footprint3

環境

  • Ubuntu 18.04
  • Kicad5.1.4
  • Python3.6

2023/07/08追記

  • Ubuntu 22.04
  • KiCad 7.0.6

で実行するとエラーが出ました。
以下の記事で別のやり方で対応しています。

「KiCad7 で PCB基板ファイルを元に footprint ライブラリを作る」
https://qiita.com/nanbuwks/items/fb2850fbe81a64d4ceeb

使いかた

kicad_pcb_to_footprint3-master.zipをダウンロードして適当な場所に展開します。

特に指定しなければ kicad_pcb_to_footprint3-master というディレクトリができるはずです。

次に、
https://github.com/pointhi/kicad-footprint-generator からも、
ZIPをダウンロード、kicad_pcb_to_footprint3-master フォルダの中に
解凍します。


kicad_pcb_to_footprint3-master
├── README.md
├── pcb_to_footprint3.py
├── kicad-footprint-generator-master
│   ├── AUTHORS.md
│   ├── KicadModTree
.
.
.

となるようにします。

pcb_to_footprint.py を編集

フットプリントに反映したいパーツを羅列します。


connector_refs = ("P1",P2","U1","U5","P3","BT1","U4","P4","P5","P7","P8")

その上で、PythonコンソールをPCBNEWから出します。

image.png

以下のようにしてpcb_to_footprint3.pyのあるディレクトリに移動します。


>>> pwd
/home/nanbuwks
>>> cd Downloads
/home/nanbuwks/Downloads
>>> cd kicad_pcb_to_footprint3-master
/home/nanbuwks/Downloads/kicad_pcb_to_footprint3-master
>>> ls
README.md
kicad-footprint-generator-master
pcb_to_footprint3.py

kicadプロジェクトのあるフォルダを以下のようにして入力します。


>>> import sys
>>> sys.argv = ['','/home/nanbuwks/storage/KiCad/MDBT50QSTICK/test']

ここではプロジェクトファイルのあるディレクトリを指定していて、出力する footprint ファイルの場所はプロジェクトファイルの場所になりますが、


>>> import sys
>>> sys.argv = ['','/home/nanbuwks/storage/KiCad/MDBT50QSTICK/test/MDBT50QSTICK.pro']

とプロジェクトファイルを指定すると、出力する footprint ファイルの場所がカレントディレクトリになります。

なお、プロジェクトファイルの場所はpcbnewのタイトルを参照。

image.png

実行します。


>>> exec(open("pcb_to_footprint3.py").read())


Found project /home/nanbuwks/storage/KiCad/MDBT50QSTICK2019/test/MDBT50QSTICK
Found pcb: /home/nanbuwks/storage/KiCad/MDBT50QSTICK2019/test/MDBT50QSTICK.kicad_pcb
origin 32, 75
writing /home/nanbuwks/storage/KiCad/MDBT50QSTICK2019/test/MDBT50QSTICK.kicad_mod
>>> 

フットプリントエディタを起動し、

image.png

「File」-「Import Footprint from KiCad File...」
でインポートします。

image.png

Edit-Footprint Properties
でプロパティを調整、
パッド番号を調整などをして、
Save as ... で保存するライブラリを指定して保存します。

7
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
0