Skip to content

Commit 286f129

Browse files
committed
More robust Altium import
For KiCad 8 and 9 See #35
1 parent d4158de commit 286f129

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77

8+
## [2.3.6] - UNRELEASED
9+
### Added
10+
- More robust Altium conversion
11+
- KiCad 8: Support for nested modals (Report + Missing font)
12+
- KiCad 9: Dismiss layer mapping
13+
14+
815
## [2.3.5] - 2024-04-03
916
### Added
1017
- IPC Netlist: Added support for CLI when using KiCad 9.0.1

interposer/interposer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ void gtk_button_set_label(GtkButton* button, const char *label)
171171
label="C_lose";
172172
else if (g_strcmp0(label, "Generate")==0)
173173
label="_Generate";
174+
else if (g_strcmp0(label, "Auto-Match Layers")==0)
175+
/* KiCad 9 importing Altium files, asking to confirm the layer mapping */
176+
label="Auto-Match _Layers";
174177
next_func(button, label);
175178
printf("GTK:Button Label:%s\n", label);
176179
if (label!=ori)

interposer/libinterposer.so

-608 Bytes
Binary file not shown.

kiauto/interposer.py

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import shutil
1313
from sys import exit, exc_info
1414
from tempfile import mkdtemp
15+
from time import sleep
1516
from threading import Thread
1617
import time
1718
from traceback import extract_stack, format_list, print_tb
@@ -600,6 +601,14 @@ def dismiss_remap_symbols(cfg, title):
600601
unknown_dialog(cfg, title, msgs)
601602

602603

604+
def dismiss_remap_layers(cfg, title):
605+
""" KiCad 9 importing Altium files """
606+
wait_queue(cfg, 'GTK:Main:In')
607+
dismiss_dialog(cfg, title, ['alt+l'])
608+
time.sleep(1)
609+
dismiss_dialog(cfg, title, ['alt+l', 'alt+o'])
610+
611+
603612
def dismiss_save_changes(cfg, title):
604613
""" KiCad 5/6 asking for save changes to disk """
605614
msgs = collect_dialog_messages(cfg, title)
@@ -621,6 +630,13 @@ def dismiss_pcb_info(cfg, title):
621630
cfg.logger.warning(msg)
622631
found = True
623632
break
633+
else:
634+
ma = re.search(r"Font '(.*)' not found; substituting '(.*)'", msg)
635+
if ma:
636+
cfg.logger.warning(f"Missing '{ma.group(1)}' font")
637+
cfg.logger.warning("KiCad message: "+msg)
638+
found = True
639+
break
624640
if not found:
625641
unknown_dialog(cfg, title, msgs, fatal=False)
626642
dismiss_dialog(cfg, title, 'Return')
@@ -709,21 +725,43 @@ def wait_start_by_msg(cfg):
709725
prg_name = 'Eeschema'
710726
unsaved = ' noname.sch'
711727
cfg.logger.info('Waiting for {} window ...'.format(prg_name))
712-
pre = 'GTK:Window Title:'
713-
pre_l = len(pre)
728+
pre1 = 'GTK:Window Title:'
729+
pre1_l = len(pre1)
730+
pre2 = 'GTK:Window Set Modal:'
731+
pre2_l = len(pre2)
714732
cfg.logger.debug('Waiting {} to start and load the {}'.format(prg_name, kind))
715733
# Inform the elapsed time for slow loads
716-
pres = [pre, 'PANGO:0:']
734+
pres = [pre1, pre2, 'PANGO:0:']
717735
elapsed_r = re.compile(r'PANGO:(\d:\d\d:\d\d)')
718736
loading_msg = 'Loading '+kind
719737
prg_msg = prg_name+' —'
720738
with_elapsed = False
739+
modals = []
721740
while True:
722741
# Wait for any window
723742
res = wait_queue(cfg, pres, starts=True, timeout=cfg.wait_start, with_windows=True)
724743
cfg.logger.debug('wait_start_by_msg got '+res)
725744
match = elapsed_r.match(res)
726-
title = res[pre_l:]
745+
title = res[pre1_l:]
746+
# The following code deals with the elusive "Report" dialog
747+
# This dialog is always created, but if filled it becomes modal
748+
if res.startswith(pre2):
749+
modal = res[pre2_l:]
750+
cfg.logger.debug(f"Detected window changing modal status: `{modal}`")
751+
if modal[-1] == '1':
752+
modals.append(modal[:-2])
753+
elif modal[-1] == '0':
754+
modals.remove(modal[:-2])
755+
if len(modals):
756+
name = modals[-1]
757+
cfg.logger.error(f'Insisting with nested modal `{name}`')
758+
dismiss_dialog(cfg, modals[-1], ['Tab', 'Return'] if name == 'Report' else 'Return')
759+
if modal == 'Report 1':
760+
# Return is not enough, OK is not the default
761+
dismiss_dialog(cfg, 'Report', ['Tab', 'Return'])
762+
elif modal == 'Edit Mapping of Imported Layers 1':
763+
dismiss_remap_layers(cfg, modal[:-2])
764+
continue
727765
if not match and with_elapsed:
728766
log.flush_info()
729767
if not cfg.ki5 and title.endswith(cfg.window_title_end):
@@ -780,5 +818,8 @@ def wait_start_by_msg(cfg):
780818
elif title == 'Report':
781819
# KiCad 8.0.3 bogus hidden dialog
782820
pass
821+
elif title == 'Edit Mapping of Imported Layers':
822+
# KiCad 9 import, we handle it on modal 1
823+
pass
783824
else:
784825
unknown_dialog(cfg, title)

0 commit comments

Comments
 (0)