From 95000c1744066d5e1425ab09f70863a7344449f7 Mon Sep 17 00:00:00 2001 From: Marco Massarelli Date: Thu, 23 Nov 2023 17:55:48 +0000 Subject: [PATCH] Add Specctra SES file import from CLI --- kibot/import_ses.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 kibot/import_ses.py diff --git a/kibot/import_ses.py b/kibot/import_ses.py new file mode 100644 index 0000000..8777874 --- /dev/null +++ b/kibot/import_ses.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import sys, getopt +import pcbnew +""" +This program runs pcbnew and imports a Specctra SES file, then saves the result +as a new KiCad PCB. +""" + +def main(argv): + board_file = '' + output_file = '' + session_file = '' + try: + opts, args = getopt.getopt(argv, "hb:s:o:",["board=","session=","output="]) + except getopt.GetoptError: + print ('import_ses.py -b -s -o ') + sys.exit(2) + for opt, arg in opts: + if opt == '-h': + print ('import_ses.py -b -s -o ') + sys.exit() + elif opt in ("-b", "--board"): + board_file = arg + elif opt in ("-s", "--session"): + session_file = arg + elif opt in ("-o", "--output"): + output_file = arg + print('Importing Specctra SES ', session_file,' for ', board_file) + board = pcbnew.LoadBoard(board_file) + pcbnew.ImportSpecctraSES(board, session_file) + success = pcbnew.SaveBoard(output_file, board, False) + if success: + print('Saved output to ', output_file) + else: + print('Couldn\'t save output to ', output_file) + +if __name__ == "__main__": + main(sys.argv[1:])