From 61bee6e9cc1bfa27eec59fa45808b4a54b1a3fce Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Thu, 1 Sep 2022 10:29:28 -0300 Subject: [PATCH] [QR_Lib][Fixed] Problems when moving the footprint to the bottom. - The updated drawings always used the top layer Fixes #271 --- CHANGELOG.md | 1 + kibot/out_qr_lib.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66cc00c5..1496c284 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Internal Netlist generation (i.e. iBoM with variants): problems withg components that doesn't specify a library. (See #242) - Problems when setting a text variable to an empty string. (#268) +- QR lib update: Problems when moving the footprint to the bottom. (#271) ### Changed - The order in which main sections are parsed is now fixed. diff --git a/kibot/out_qr_lib.py b/kibot/out_qr_lib.py index 73cadc0d..e1ce8396 100644 --- a/kibot/out_qr_lib.py +++ b/kibot/out_qr_lib.py @@ -318,14 +318,29 @@ class QR_LibOptions(BaseOptions): f.write(dumps(lib)) f.write('\n') + @staticmethod + def find_layer(sexp, def_layer): + """ Determine the layer. + The user could move the footprint to the bottom layer """ + # Look for the polys + poly = next(filter(lambda s: is_symbol('fp_poly', s), sexp), None) + if not poly: + return def_layer + layer = next(filter(lambda s: is_symbol('layer', s), poly), None) + if not layer or len(layer) != 2: + return def_layer + return layer[1] + def update_footprint(self, name, sexp, qr): logger.debug('- Updating QR footprint: '+name) # Compute the size qrc, size, full_size, center, size_rect = compute_size(qr, is_sch=False) + # In which layer are the drawings? (default to the original) + layer = self.find_layer(sexp, qr.layer) # Remove old drawing sexp[:] = list(filter(lambda s: not is_symbol('fp_poly', s), sexp)) # Add the new drawings - sexp.extend(self.qr_draw_fp(size, size_rect, center, qrc, qr.pcb_negative, qr.layer, do_sep=False)) + sexp.extend(self.qr_draw_fp(size, size_rect, center, qrc, qr.pcb_negative, layer, do_sep=False)) # Update the fields for s in sexp: if (is_symbol('fp_text', s) and len(s) > 2 and isinstance(s[1], Symbol) and s[1].value() == 'user' and